I have the same question -- for content created with an AJAX call, where do you place the script so that it affects the content or do you use .live() or .delegate()?
This seems to be a complex problem, as no one has given an answer as of yet. I so wish the tutorial I linked to had incorporated getting javascript to work.
inside the guts div. This code works when I go to the specific page url. However whenever I click using the navigation and the same page is generated by ajax, the script does not load.
I take it I must put the $getscript somewhere inside the dynamicpage.js so it is passed onto the ajax loaded content?
Very confused and would love to know how to get this working. I have searched for days for tutorials and am having no luck.
why don't you put the javascript you're loading into a function in the main js file, then call that function after the page has loaded, this would be a performance gain too as it would only need to be parsed once
Ok I am still struggling to load two scrips. Basically I have script.js, and cycleall.js
I have 2 images on the page, and they are going to be a slideshow which fades between the two images. I need the script.js which hides the 1 slide and cycleall.js which will do the fade transitions.
I thought it would be a simple matter of just adding two get scripts with the names of these scripts and it would work.
You can see that it does work on projects2.php however the generated ajax page it doesnt work. This puzzles me as my test script worked on the ajax generated page.
How would I go about getting javascript to work with AJAX displayed content based on that tutorial?
Many thanks.
http://api.jquery.com/jQuery.getScript/
Here is the content of that test script
I have placed
inside the guts div.
This code works when I go to the specific page url. However whenever I click using the navigation and the same page is generated by ajax, the script does not load.
I take it I must put the $getscript somewhere inside the dynamicpage.js so it is passed onto the ajax loaded content?
Very confused and would love to know how to get this working. I have searched for days for tutorials and am having no luck.
Here is the code for my single test script.
I have 2 images on the page, and they are going to be a slideshow which fades between the two images. I need the script.js which hides the 1 slide and cycleall.js which will do the fade transitions.
I thought it would be a simple matter of just adding two get scripts with the names of these scripts and it would work.
You can see that it does work on projects2.php however the generated ajax page it doesnt work. This puzzles me as my test script worked on the ajax generated page.