Mootools AJAX help

Discussion in 'Web Design and Development' started by Ad Pro, May 3, 2009.

  1. Ad Pro macrumors member

    Joined:
    Jul 4, 2007
    Location:
    UK
    #1
    Hi, I am have a problem with some Mootools code I am trying to put together.

    The site I am working on (a portfolio type site) has a list of links down the left and a main content area on the right. The content area is populated dynamically via AJAX when the the links are clicked. The main content area needs to display a set of images in tabs which also uses Mootools to work.

    The problem is the tabs do not work, it would appear that the AJAX is not loading the javascript content.

    I am using Mootools request.HTML, the code is as follows:

    PHP:
    window.addEvent('domready', function() {
            
        var 
    req = new Request.HTML({url:'data.html'evalScripts:trueevalResponse:true,
            
    onSuccess: function(html) {
                $(
    'result').set('text''');
                $(
    'result').adopt(html);
            },
            
    onFailure: function() {
                $(
    'result').set('text''The request failed.');
            }
        });
        $(
    'makeRequest').addEvent('click', function() {
            
    req.send();
        });
    });
    I hope this makes sense, thanks in advance for any help.
     
  2. phantax macrumors member

    Joined:
    Feb 2, 2009
    #2
    You are going to need to call the functions after the content load with something like this.

    You need to use the onComplete function to run any javascript after the content is loaded, my example function here is update_winheight();

    Code:
    var req = new Request.HTML({
            url:config_url,
    	method: 'get',
    	evalScripts: true,
    	update: data_window,
    	onComplete: function() {
    		update_winheight();
    	}
    }).send();
    
     

Share This Page