From 3d1a420a6f32662567a26fb1cfa6cd938ab06715 Mon Sep 17 00:00:00 2001 From: ninadsp Date: Wed, 4 Aug 2010 21:54:35 +0530 Subject: [PATCH] Moved the code that appends the inline edit anchor into a function and registered it to all Ajax events that complete successfully. The anchor is now appended even after retrieving results over Ajax. --- js/sql.js | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/js/sql.js b/js/sql.js index 578497bbb..eeac2f48d 100644 --- a/js/sql.js +++ b/js/sql.js @@ -5,6 +5,13 @@ * @version $Id$ */ +/** + * Get the field name for the current field. Required to construct the query + * for inline editing + * + * @param this_field_obj jQuery object that points to the current field's tr + * @param disp_mode string + */ function getFieldName(this_field_obj, disp_mode) { if(disp_mode == 'vertical') { @@ -26,20 +33,16 @@ function getFieldName(this_field_obj, disp_mode) { return field_name; } -$(document).ready(function() { - - /** - * @var disp_mode current value of the direction in which the table is displayed - */ - var disp_mode = $("#top_direction_dropdown").val(); - - $("#top_direction_dropdown, #bottom_direction_dropdown").live('change', function(event) { - disp_mode = $(this).val(); - }) - +/** + * The function that iterates over each row in the table_results and appends a + * new inline edit anchor to each table row. + * + * @param string disp_mode + */ +function appendInlineAnchor(disp_mode) { if(disp_mode == 'vertical') { var cloned_row = $('.edit_row_anchor').removeClass('edit_row_anchor').parent('tr').clone(); - + $(cloned_row).find('td').addClass('edit_row_anchor') .find('a').attr('href', '#') .find('img').attr('title', 'Inline Edit'); @@ -70,6 +73,24 @@ $(document).ready(function() { } }) } +} + +$(document).ready(function() { + + /** + * @var disp_mode current value of the direction in which the table is displayed + */ + var disp_mode = $("#top_direction_dropdown").val(); + + $("#top_direction_dropdown, #bottom_direction_dropdown").live('change', function(event) { + disp_mode = $(this).val(); + }) + + appendInlineAnchor(disp_mode); + + $("#sqlqueryresults").ajaxSuccess(function() { + appendInlineAnchor(disp_mode); + }) $('') .html(PMA_messages['strToggleQueryBox'])