dfe1a6f707a279943377e66a8947f32b9a7fc486

Author: AD7six

Date: 2009-02-27 23:19:37 +0100

using .ajax 'extension' to maintain the correct url and avoid cache confusion

diff --git a/config/routes.php b/config/routes.php index 3d0ebd0..7c3f425 100644 --- a/config/routes.php +++ b/config/routes.php @@ -32,7 +32,7 @@ if (!empty($fromUrl)) { Router::connectNamed(array('node', 'user', 'language', 'status', 'query', 'collection'), array('default' => true)); } } -Router::parseExtensions('rss', 'xml'); +Router::parseExtensions('rss', 'xml', 'ajax'); // Legacy Router::connect('/chapter/*', array('controller' => 'redirect', 'action' => 'process', 'chapter')); Router::connect('/appendix/*', array('controller' => 'redirect', 'action' => 'process', 'appendix')); diff --git a/webroot/js/scripts.js b/webroot/js/scripts.js index b91d294..8241770 100644 --- a/webroot/js/scripts.js +++ b/webroot/js/scripts.js @@ -62,12 +62,15 @@ $(document).ready(function() { $('#tocFull').dialog('open'); return false; }); + /** + * Dialogs - use .ajax suffix to ensure full page view caching doesn't get confused + */ $('ul.dialogs a') .click(function(){ $('<div class="dialog" style="display;none">Loading...</div>') .attr('title', $(this).text()) .appendTo('body') - .load($(this).attr('href') + '/.ajax', function(){ + .load($(this).attr('href') + '.ajax', function(){ containLinks(this); }).dialog({ autoOpen: false, @@ -77,11 +80,14 @@ $(document).ready(function() { }) .dialog('open'); return false; - }) + }); + /** + * containLinks, for the passed base find any links within it and ajax load into the same container + */ function containLinks (base) { var base = $(base); $('a', base).click(function() { - base.load($(this).attr('href') + '/.ajax', function() { + base.load($(this).attr('href') + '.ajax', function() { containLinks(base); }); return false;