diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 91e7a16ee3..5f622be577 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -30,9 +30,58 @@ AJAX.registerTeardown('tbl_structure.js', function() { $("#table_index tbody tr td.edit_index.ajax, #indexes .add_index.ajax").die('click'); $('#index_frm input[type=submit]').die('click'); $("#move_columns_anchor").die('click'); + $(".append_fields_form.ajax").unbind('submit'); }); AJAX.registerOnload('tbl_structure.js', function() { + + /** + *Ajax action for submitting the "Column Change" and "Add Column" form + */ + $(".append_fields_form.ajax").bind('submit', function(event) { + event.preventDefault(); + /** + * @var the_form object referring to the export form + */ + var $form = $(this); + + /* + * First validate the form; if there is a problem, avoid submitting it + * + * checkTableEditForm() needs a pure element and not a jQuery object, + * this is why we pass $form[0] as a parameter (the jQuery object + * is actually an array of DOM elements) + */ + if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) { + // OK, form passed validation step + PMA_prepareForAjaxRequest($form); + //User wants to submit the form + PMA_ajaxShowMessage(); + $.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function(data) { + if ($("#sqlqueryresults").length != 0) { + $("#sqlqueryresults").remove(); + } else if ($(".error").length != 0) { + $(".error").remove(); + } + if (data.success == true) { + $("
").prependTo("#page_content"); + $("#sqlqueryresults").html(data.sql_query); + $("#result_query .notice").remove(); + $("#result_query").prepend(data.message); + /* Reload the field form */ + if ($("#fieldsForm").length) { + reloadFieldForm(data.message); + } else { + PMA_ajaxShowMessage(data.message); + } + PMA_reloadNavigation(); + } else { + PMA_ajaxShowMessage(data.error, false); + } + }); // end $.post() + } + }); // end change table button "do_save_data" + /** * Attach Event Handler for 'Change Column' */ @@ -374,62 +423,6 @@ AJAX.registerOnload('tbl_structure.js', function() { }); }); -/** - * jQuery coding for 'Change Table' and 'Add Column'. - * Attach Ajax Event handlers for Change Table - */ -AJAX.registerTeardown('tbl_structure.js', function() { - $(".append_fields_form.ajax").unbind('submit'); -}); -AJAX.registerOnload('tbl_structure.js', function() { - /** - *Ajax action for submitting the "Column Change" and "Add Column" form - */ - $(".append_fields_form.ajax").bind('submit', function(event) { - event.preventDefault(); - /** - * @var the_form object referring to the export form - */ - var $form = $(this); - - /* - * First validate the form; if there is a problem, avoid submitting it - * - * checkTableEditForm() needs a pure element and not a jQuery object, - * this is why we pass $form[0] as a parameter (the jQuery object - * is actually an array of DOM elements) - */ - if (checkTableEditForm($form[0], $form.find('input[name=orig_num_fields]').val())) { - // OK, form passed validation step - PMA_prepareForAjaxRequest($form); - //User wants to submit the form - PMA_ajaxShowMessage(); - $.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function(data) { - if ($("#sqlqueryresults").length != 0) { - $("#sqlqueryresults").remove(); - } else if ($(".error").length != 0) { - $(".error").remove(); - } - if (data.success == true) { - $("").prependTo("#page_content"); - $("#sqlqueryresults").html(data.sql_query); - $("#result_query .notice").remove(); - $("#result_query").prepend(data.message); - /* Reload the field form */ - if ($("#fieldsForm").length) { - reloadFieldForm(data.message); - } else { - PMA_ajaxShowMessage(data.message); - } - PMA_reloadNavigation(); - } else { - PMA_ajaxShowMessage(data.error, false); - } - }); // end $.post() - } - }); // end change table button "do_save_data" -}); - /** * Reload fields table */