-
☆ A M B ☆
- 24,524 Posts
You can do that using the jQuery load() function; it allows you to specify the HTML container (such as a div) that you want to use. See the section on "loading page fragments" here
http://api.jquery.com/load/
Thanks Susan. I know how to do the jquery part, but the MODx part I am unsure about. I'll try and explain it a bit better...
If a visitor visits www.mydomain.com/about-us.html they see the full page with template. If they arrive at www.mydomain.com/index.html and click the about us link it loads the about-us.html page into a div (using the $ load function) but a snippet on that page knows from an identifier of some kind (such as $_REQUEST['ajax'] ) not to load the whole template, but just the content part on the request. So (ignoring the JQuery part) is it possible to allocate a template to a page but on calling that page can the template be disregarded from within a snippet?
-
☆ A M B ☆
- 24,524 Posts
-
☆ A M B ☆
- 24,524 Posts
Your AJAX load() can specify the element that you want inserted into the div. For example, if you want the main content area, just specify the div (or section or whatever) you have the [*content*] tags in.
$('#result').load('about-us.html #main');
Now the whole page will be returned, but the load() function will pick out the content in the #main div or section to load into your #result div or section. The rest of the page will be discarded.
Ah, now that is something I haven't done before. I will try that. So my question was a JQuery one after all!
Thanks for your help.