Mootools equivalent for jQuery ajax request

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
asle
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Mon Apr 02, 2007 11:19 am

Mootools equivalent for jQuery ajax request

Postby asle » Tue Dec 09, 2008 2:41 pm

Hi,
Joomla! 1.5.7
I am a bit lost with MooTools since I have worked mainly with jQuery. If I load jQuery (with JDOC) I get this error:
js error:el.set is not a function on mootools.js line 23 - and Accordion Menu (mootools) does not work anymore.

I feel that I will have to ditch jQuery for MooTools but that is sad. I want to work with Joomla but I am only confident with jQuery. Anyway - is there a way to do this in MooTools?
- Get the "rel" value of the link and send it to an external page. Fill the result in div "detail". This is jQuery working:

Code: Select all

$(document).ready(function() {
$(".detail").click(function(){
  var did = $(this).attr("rel");
  $.post("/code/getDetails.php", {id:did}, function(data){
       $("#detail").html(data);
   });
    });
});

HTML:
<div id="detail"</div>
<a href="#" rel="123">Product link</a>
<a href="#" rel="678">Product link</a>
<a href="#" rel="256">Product link</a>

Glad for any ideas!
/asle

roba121
Joomla! Explorer
Joomla! Explorer
Posts: 465
Joined: Tue Jun 13, 2006 12:20 pm

Re: Mootools equivalent for jQuery ajax request

Postby roba121 » Tue Dec 09, 2008 3:49 pm

if you want to use mootools and jquery together you need to use jquerys no conflict mode.

Before you run your code and just after you include the jquery.js do this

$j = jQuery.noConflict();

then replace all the $ with $j in your jquery code and you should be good.

Hth

Rob

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: Mootools equivalent for jQuery ajax request

Postby pollen8 » Wed Dec 10, 2008 10:19 am

Code: Select all

var myAjax = new Ajax('/code/getDetails.php',
         {
            'data':{
            'id':did
            },
            'onComplete':function(data){
               $("detail").setHTML(data);
            }
         });

document.addEvent('domready', function(){
   document.getElements(".detail").addEvent(function(e){
      var event = new Event(e);
      event.stop();
      var did = $(event.target).rel;
      myAjax.options.data.id = did;
      myAjax.request();
   });
});
aka

asle
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Mon Apr 02, 2007 11:19 am

Re: Mootools equivalent for jQuery ajax request

Postby asle » Sat Dec 13, 2008 3:12 pm

Thanks Rob for your suggestion.
I get an error: ".. did is not defined" on
var myAjax = new Ajax('/code/getDetails.php',
{
'data':{
'id':did{

So I tried to put everything inside
document.addEvent('domready', function(){
- Still nothing happens. No errors and nothing in FireBug.
/asle

User avatar
pollen8
Joomla! Explorer
Joomla! Explorer
Posts: 350
Joined: Wed Aug 17, 2005 10:32 pm
Location: la Rochelle - France
Contact:

Re: Mootools equivalent for jQuery ajax request

Postby pollen8 » Mon Dec 15, 2008 4:27 pm

perhaps replace

'data':{
'id':did
}

with

'data':{}
aka


Return to “Joomla! 1.5 Coding”

Who is online

Users browsing this forum: No registered users and 5 guests