views:

31

answers:

1

Hi,I'm trying to have the users click on the links in an article, but have the results open in the same article (so the article reloads and open the target page in itself, like it would if it was in an iframe, right now it reloads the whole page), I do not want to use the main menu, and would also like to avoid using iframes, normally if this was HTML I'd use ajax or something similar, but in joomla i'm not sure, any suggestions?

A: 

If you have HTML ids you are better of using AJAX, Joomla has jquery and mootols to make your life easier. There are couple of things you should know

  1. Look into JUMI, it will allow you to use PHP within your articles. Can be very helpful. You can use it to add javascript framework from article for your ajax like so <?php JHTML::_('behavior.mootools'); ?>

  2. You want to be careful while editing the article, if you use editor it will strip out your JavaScript from the article. You are better of just using "No-Editor" or if you are using JCE switch to text by pressing "Show/Hide" just above the editor in the left corner.

  3. Add events to your IDs in domready instead of inline js. Something like this

/* MooTools Example */
window.addEvent('domready', function(){
    $('link-1').addEvent('click', function(){ new Ajax(...).request(); });
    $('link-2').addEvent('click', function(){ new Ajax(...).request(); });
    $('link-3').addEvent('click', function(){ new Ajax(...).request(); });
});
Alex