Modified it to support the Ajax action on tbl_addfield.php
[phpmyadmin/ninadsp.git] / js / tbl_addfield.js
blobc2674e11847ab99114a1cc75bc6351a2322ac629
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  * @fileoverview    functions used on the Table Add Field page
4  * @name            Table Add Field
5  *
6  * @requires    jQuery
7  * @requires    jQueryUI
8  * @requires    js/functions.js
9  *
10  */
12 $(document).ready(function() {
14     /**
15      * AJAX event handler for 'Add/Save Field'
16      *
17      */
18     $("#add_field_form").delegate("input[name=submit_num_fields], input[name=do_save_data]", 'click', function(event) {
19         event.preventDefault();
21         /**
22          *  @var    the_form    object referring to the create table form
23          */
24         var the_form = $("#add_field_form");
26         PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
27         $(the_form).append('<input type="hidden" name="ajax_request" value="true" />');
29         if($(this).attr('name') == 'submit_num_fields') {
30             //User wants to add more fields to the table
31             $.post($(the_form).attr('action'), $(the_form).serialize() + "&submit_num_fields=" + $(this).val(), function(data) {
32                 $("#add_field_form").html(data);
33                 PMA_ajaxShowMessage("");
34             }) //end $.post()
35         }
36         else if($(this).attr('name') == 'do_save_data') {
37             $.post($(the_form).attr('action'), $(the_form).serialize() + "&do_save_data=" + $(this).val(), function(data) {
38                 if(data.success == true) {
39                     PMA_ajaxShowMessage(data.message);
40                 }
41                 else {
42                     PMA_ajaxShowMessage(data.error);
43                 }
44             })
45         }
46     });
47 });