jQuery - something is missing PLEASE HELP ! |
[eluser]blorriman[/eluser]
OK, this doesn't make any sense to me, and I've been staring at it too long so hopefully someone else will spot the problem. I'm trying to replace content in a div with another page - but when I do, javascript no longer works in the new page. Here is the simple test page : Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" and here is the page being loaded : Code: [removed] But when I test this the test-js page replaces the test3 div no problem, but the test5 div does not get hidden - which tells me javascript is NOT working. Any suggestions would be greatly appreciated.
[eluser]Georgi Budinov[/eluser]
Which version of JQuery are you using, because the code is removed ... I remember I had struggled with the exact same problem with an older version of JQuery -> it didn't eval the scripts in the loaded pages. At that time I had to mess with the jquery code because I needed the exact version that was buggy ... for my pity I don't remember which one was it and was it official release at all. Edit: Does the test4 get shown ?
[eluser]blorriman[/eluser]
I'm using the Google link: http://ajax.googleapis.com/ajax/libs/jqu...ery.min.js And test4 does not show - that's how I know javascript is not working.
[eluser]Georgi Budinov[/eluser]
So it is the latest ... I will have to try that out, but in the meantime you can try setting the callback on the load method to show / hide the divs - something like this: Code: $("#test3").load( $(this).attr("href") + " #jQuery-content", function(){
[eluser]Georgi Budinov[/eluser]
OK I found your problem. That is a feature from the load function that I didn't know until now ... When they got it ? .... $(this).attr("href") + " #jQuery-content" is essencially somthing like '/index.php #jQuery-content' which means that the load method will parse the output and get just that part of the output removing anything else including your script tag ! http://api.jquery.com/load/ Quote:We could modify the example above to use only part of the document that is fetched:
[eluser]blorriman[/eluser]
Thank you Georgi . . . it was adding the show/hide to the .load that did it ! Code: .load( $(this).attr("href") + " #jQuery-content", function() { Thanks for your help. Cheers, Bob |
Welcome Guest, Not a member yet? Register Sign In |