Hi Marc,
On 14 Mei 2011, at 18:39, Marc Delisle marc@infomarc.info wrote:
Le 2011-05-13 16:06, Aris Feryanto a écrit :
Hi,
The recently used tables is now using ajax. I've just pushed to my repo, so the demo [0] will be available in an hour later. Comment and suggestion are welcome, mainly regarding the ajax-related code: - ajax request in navigation.js - ajax response in navigation.php - ajax trigger in header.inc.php (the triggering is done by adding
<script> tag to call js function in the navigation frame, any better way?)
Hi Aris, How about this?
diff --git a/js/functions.js b/js/functions.js index 572c857..50fd6f8 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2276,5 +2276,9 @@ $(document).ready(function() { } });
$('#update_recent_tables').ready(function() {
window.parent.frame_navigation.PMA_reloadRecentTable();
});
}) // end of $(document).ready()
diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 05d272e..4036f86 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -21,9 +21,7 @@ require_once './libraries/RecentTable.class.php'; function PMA_addRecentTable($db, $table) { $tmp_result = RecentTable::getInstance()->add($db, $table); if ($tmp_result === true) {
echo '<script type="text/javascript">' .
'window.parent.frame_navigation.PMA_reloadRecentTable();' .
'</script>';
} else { $error = $tmp_result; $error->display();echo '<span class="hide" id="update_recent_tables"></span>';
This works. But, I'm thinking that we should add a function to register javascript for a certain page, shouldn't we? The registered script will be buffered for output, for example, near the bottom of the page. The function will look like this:
PMA_registerScript ( $scriptString );
Since, IMO, the code will be clearer and easier to understand than separated code in both the php and the js.
-- Aris Feryanto