Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ad Pro

macrumors member
Original poster
Jul 4, 2007
86
0
UK
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:true, evalResponse: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.
 
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();
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.