I have page A and pageB.
Page A loads page B into a div.
There are divs in page B that I when I want to execute functions onclick.
The problem is that no matter where I place pageB’s javascript it doesn’t work.
I assumed that if i had a function ot initalise pagesB’s javascript after it was loaded into the div this would work… but no success…
Any responses would be very helpful… regards J
If you’re loading Page B with ajax, then most likely the javascript inside Page B is getting stripped out. This is due to a security concern.
An alternative way to get this to work would be that you separate your structure like this
Now, when you load Page A you should load the following:
Then, when you make your ajax call to load Page B HTML, you simply call the Page B javascript (which is already loaded) and everything should work.
Here’s an example of what I’m describing:
http://jsfiddle.net/josephbulger/zSmQE/