0

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:

  1. There is a containing HTML page with a DIV which the xslt will be displayed into.
  2. The xslt file of course which is very simple.. just display a couple of XML elements into <p> tags.
  3. The XML dynamically generated.

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!

1
  • does that id is predictable? also, the xml scheme has any type of pattern that you can use (e.g. a serie of divs could be assigned to a funcion in jquery using $('#container > div').live(function () { ... }) ) Commented Nov 14, 2009 at 22:51

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.