diff --git a/js/db_operations.js b/js/db_operations.js index b25fd53545..329bd56d0a 100644 --- a/js/db_operations.js +++ b/js/db_operations.js @@ -48,10 +48,7 @@ AJAX.registerOnload('db_operations.js', function() { PMA_ajaxShowMessage(data.message); PMA_commonParams.set('db', data.newname); - PMA_reloadNavigation(); - // without this timeout, when looking in the navigation - // tree for the new db name, I only find the old name - setTimeout(function() { + PMA_reloadNavigation(function() { $('#pma_navigation_tree') .find("a:not('.expander')") .each(function(index) { @@ -62,7 +59,7 @@ AJAX.registerOnload('db_operations.js', function() { $thisAnchor.trigger('click'); } }); - }, 500); + }); } else { PMA_ajaxShowMessage(data.error, false); } diff --git a/js/navigation.js b/js/navigation.js index 0ab9f73794..635869ac0f 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -220,9 +220,10 @@ $(function() { /** * Reloads the whole navigation tree while preserving its state * + * @param function the callback function * @return void */ -function PMA_reloadNavigation() { +function PMA_reloadNavigation(callback) { var $throbber = $('#pma_navigation .throbber') .first() .css('visibility', 'visible'); @@ -230,7 +231,7 @@ function PMA_reloadNavigation() { reload: true, pos: $('#pma_navigation_tree').find('a.expander:first > span.pos').text() }; - // Trasverse the navigation tree backwards to generate all the actual + // Traverse the navigation tree backwards to generate all the actual // and virtual paths, as well as the positions in the pagination at // various levels, if necessary. var count = 0; @@ -271,6 +272,10 @@ function PMA_reloadNavigation() { $throbber.css('visibility', 'hidden'); if (data.success) { $('#pma_navigation_tree').html(data.message).children('div').show(); + // Fire the callback, if any + if (typeof callback === 'function') { + callback.call(); + } } else { PMA_ajaxShowMessage(data.error); }