Skip to content

Commit

Permalink
Ajaxify table options form on tbl_operations.php
Browse files Browse the repository at this point in the history
  • Loading branch information
roccivic committed Oct 30, 2012
1 parent 289f66e commit 1379cf8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
29 changes: 29 additions & 0 deletions js/functions.js
Expand Up @@ -2043,6 +2043,7 @@ AJAX.registerOnload('functions.js', function() {
AJAX.registerTeardown('functions.js', function() {
$("#copyTable.ajax").die('submit');
$("#moveTableForm").die('submit');
$("#tableOptionsForm").die('submit');
$("#tbl_maintenance li a.maintain_action.ajax").die('click');
});
/**
Expand Down Expand Up @@ -2106,6 +2107,34 @@ AJAX.registerOnload('functions.js', function() {
}); // end $.post()
});

/**
* Ajax action for submitting the "Table options"
*/
$("#tableOptionsForm").live('submit', function(event) {
event.preventDefault();
event.stopPropagation();
var $form = $(this);
var $tblNameField = $form.find('input[name=new_name]');
if ($tblNameField.val() !== $tblNameField[0].defaultValue) {
// reload page and navigation if the table has been renamed
PMA_prepareForAjaxRequest($form);
var tbl = $tblNameField.val();
$.post($form.attr('action'), $form.serialize(), function(data) {
if (data.success == true) {
PMA_commonParams.set('table', tbl);
$('#page_content').replaceWith(
"<div id='page_content'>" + data.message + "</div>"
);
$('html, body').animate({scrollTop: 0}, 'fast');
} else {
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
} else {
$form.removeClass('ajax').submit().addClass('ajax');
}
});

/**
*Ajax events for actions in the "Table maintenance"
**/
Expand Down
3 changes: 2 additions & 1 deletion libraries/operations.lib.php
Expand Up @@ -721,7 +721,8 @@ function PMA_getTableOptionDiv($comment, $tbl_collation, $tbl_storage_engine,
$transactional, $page_checksum, $is_innodb, $is_pbxt, $is_aria, $checksum
) {
$html_output = '<div class="operations_half_width clearfloat">';
$html_output .= '<form method="post" action="tbl_operations.php">';
$html_output .= '<form method="post" action="tbl_operations.php"';
$html_output .= ' id="tableOptionsForm" class="ajax">';
$html_output .= PMA_generate_common_hidden_inputs(
$GLOBALS['db'], $GLOBALS['table']
);
Expand Down

0 comments on commit 1379cf8

Please sign in to comment.