From cbe82879e863f542404ceaf79864bb680a2fb2dc Mon Sep 17 00:00:00 2001 From: ninadsp Date: Sat, 10 Jul 2010 17:14:10 +0530 Subject: [PATCH] Hooked in Ajax submission of data. Changint the number of insertions on the fly is still a work in progress. Insertion tables are being cloned/deleted, however, each is not unique. --- js/tbl_change.js | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/js/tbl_change.js b/js/tbl_change.js index 36c4303ef..47f3592e0 100755 --- a/js/tbl_change.js +++ b/js/tbl_change.js @@ -247,3 +247,75 @@ function unNullify(urlField, multi_edit) return true; } // end of the 'unNullify()' function + +/** + * Ajax handlers for this page + */ +$(document).ready(function() { + + //Submission of data to be inserted into table + $("#insertForm").live('submit', function(event) { + + var the_form = $(this); + event.preventDefault(); + + PMA_ajaxShowMessage(); + $(the_form).append(''); + + $.post($(the_form).attr('action'), $(the_form).serialize(), function(data) { + if(data.success == true) { + PMA_ajaxShowMessage(data.message); + $("#topmenucontainer").after(data.sql_query); + $(the_form).find('input:reset').trigger('click'); + } + else { + PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : "+data.error, "7000"); + } + }) + }) // end submission of data to be inserted into table + + //Restart Insertion form + $("#insert_rows").live('change', function(event) { + event.preventDefault(); + + var curr_rows = $(".insertRowTable").length; + var target_rows = $("#insert_rows").val(); + + if(curr_rows < target_rows ) { + while( curr_rows < target_rows ) { + var last_row = $("#insertForm").find(".insertRowTable:last"); + //var name = $(last_row).find('input[name^=fields_name]').attr('name'); + + //Clone the insert tables + $(last_row) + .clone() + .insertBefore("#insertForm > fieldset"); + + //Insert/Clone the ignore checkboxes + if(curr_rows == 1 ) { + $('') + .insertBefore(".insertRowTable:last") + .after(''); + } + else { + $("#insertForm") + .children('input:checkbox:last') + .add('label[for^=insert_ignore_check]:last') + .clone() + .before('
') + .insertBefore(".insertRowTable:last"); + } + curr_rows++; + } + } + else if( curr_rows > target_rows) { + while(curr_rows > target_rows) { + $("input[id^=insert_ignore_check]:last") + .nextUntil("fieldset") + .andSelf() + .remove(); + curr_rows--; + } + } + }) +}, 'top.frame_content'); //end Ajax handlers \ No newline at end of file