make USE work in the context of ajaxification
This commit is contained in:
23
js/sql.js
23
js/sql.js
@@ -155,14 +155,17 @@ $(document).ready(function() {
|
|||||||
* @memberOf jQuery
|
* @memberOf jQuery
|
||||||
* @name appendToggleSpan
|
* @name appendToggleSpan
|
||||||
*/
|
*/
|
||||||
|
// do not add this span more than once
|
||||||
|
if (! $('#sqlqueryform').find('span').is('#togglequerybox')) {
|
||||||
$('<span id="togglequerybox"></span>')
|
$('<span id="togglequerybox"></span>')
|
||||||
.html(PMA_messages['strToggleQueryBox'])
|
.html(PMA_messages['strToggleQueryBox'])
|
||||||
.appendTo("#sqlqueryform");
|
.appendTo("#sqlqueryform");
|
||||||
|
|
||||||
// Attach the toggling of the query box visibility to a click
|
// Attach the toggling of the query box visibility to a click
|
||||||
$("#togglequerybox").live('click', function() {
|
$("#togglequerybox").bind('click', function() {
|
||||||
$(this).siblings().slideToggle("medium");
|
$(this).siblings().slideToggle("medium");
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax Event handler for 'SQL Query Submit'
|
* Ajax Event handler for 'SQL Query Submit'
|
||||||
@@ -173,17 +176,29 @@ $(document).ready(function() {
|
|||||||
*/
|
*/
|
||||||
$("#sqlqueryform").live('submit', function(event) {
|
$("#sqlqueryform").live('submit', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
$form = $(this);
|
||||||
PMA_ajaxShowMessage();
|
PMA_ajaxShowMessage();
|
||||||
|
|
||||||
$(this).append('<input type="hidden" name="ajax_request" value="true" />');
|
if (! $form.find('input:hidden').is('#ajax_request_hidden')) {
|
||||||
|
$form.append('<input type="hidden" id="ajax_request_hidden" name="ajax_request" value="true" />');
|
||||||
|
}
|
||||||
|
|
||||||
$.post($(this).attr('action'), $(this).serialize() , function(data) {
|
$.post($(this).attr('action'), $(this).serialize() , function(data) {
|
||||||
if(data.success == true) {
|
if(data.success == true) {
|
||||||
PMA_ajaxShowMessage(data.message);
|
PMA_ajaxShowMessage(data.message);
|
||||||
|
// this happens if a USE command was typed
|
||||||
|
if (typeof data.reload != 'undefined') {
|
||||||
|
$form.find('input[name=db]').val(data.db);
|
||||||
|
// need to regenerate the whole upper part
|
||||||
|
$form.find('input[name=ajax_request]').remove();
|
||||||
|
$form.append('<input type="hidden" name="reload" value="true" />');
|
||||||
|
$.post('db_sql.php', $form.serialize(), function(data) {
|
||||||
|
$('body').html(data);
|
||||||
|
}); // end inner post
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (data.success == false ) {
|
else if (data.success == false ) {
|
||||||
PMA_ajaxShowMessage(data.error);
|
PMA_ajaxShowMessage(data.error, 50000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#sqlqueryresults").html(data);
|
$("#sqlqueryresults").html(data);
|
||||||
|
5
sql.php
5
sql.php
@@ -677,7 +677,10 @@ if (0 == $num_rows || $is_affected) {
|
|||||||
if(isset($GLOBALS['display_query'])) {
|
if(isset($GLOBALS['display_query'])) {
|
||||||
$extra_data['sql_query'] = PMA_showMessage(NULL, $GLOBALS['display_query']);
|
$extra_data['sql_query'] = PMA_showMessage(NULL, $GLOBALS['display_query']);
|
||||||
}
|
}
|
||||||
|
if ($GLOBALS['reload'] == 1) {
|
||||||
|
$extra_data['reload'] = 1;
|
||||||
|
$extra_data['db'] = $GLOBALS['db'];
|
||||||
|
}
|
||||||
PMA_ajaxResponse($message, $message->isSuccess(), (isset($extra_data) ? $extra_data : ''));
|
PMA_ajaxResponse($message, $message->isSuccess(), (isset($extra_data) ? $extra_data : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user