Reputation:
Sorry if the title doesn't explain things well.
I have a situation where I am using DHTMLX AJAX component to display XSLT out to HTML. So the idea is this:
<p>
tags.Now all works well, it renders the output perfectly on most of the later browsers, and the rendering etc isn't the problem...
What I want to do now is to use JQuery to do something simple like show/hide a
tag etc.. which has a unique id of course.
The way I am doing it is to add the JQuery include into the HTML containing page, and have some Javascript/JQuery in the HEAD section of that HTML page - i.e. like you would normally if just a plain old HTML page.
JQuery doesn't seem to "see" the <p id='test'>
tag which is rendered from the XSLT? even though (to best of my knowledge) the XSLT is valid/formed well and displays perfectly ok?
Something silly I am obviously missing ... either conceptually or coding wise???
Thanks in advance, any help grateful!
Upvotes: 0
Views: 437
Reputation: 2291
The jQuery code may be running before your AJAX code finishes. Try the live function:
http://docs.jquery.com/Events/live
live() binds events to current and future elements that match a selector.
Upvotes: 3
Reputation: 532435
If the XML is loaded via AJAX, then you'll need to apply the jQuery function on the element after it's loaded or using a live handler (depending on the event you are handling). If you attempt to apply it on page load without using a live handler, then the element doesn't yet exist and thus the selector won't match it and any handlers won't be applied.
Upvotes: 2