views:

159

answers:

2

I want to load content via the jquery load function however inside the page that is loaded i have other links which I want to load over the top of the previously loaded content.

see the link below for a simple example of what I am trying to achieve but it does not work however. Any pointers/tips would be amazing.

cheers

http://pastebin.com/m58a7da86

A: 

Maybe

$('#loadspace').html('').load(toLoad, '', [...]

will help?

Ionut Staicu
+1  A: 

I believe you need to look into event delegation. If you hook up a click event to the div and then give any anchors you want to load content by ajax a certain class. You can then check if the click was invoked by one of these anchors by using the event.target

jQuery 1.3 has a .live method which would help you in this situation. This basically allows you to bind to a selector even if it is not yet in the dom. However that is still in Beta so i wouldnt advis3e an instant upgrade for something that is quite easy to roll yourself.

This should help you on your way.

redsquare