Chris
Chris

Reputation: 151

waitForKeyElements doesn't recognize selector, with "$"? On reload of same id?

So I am trying to use the waitForKeyElements() function in order to detect AJAX content. The div I am trying to select has a "$" in its ID (e.g. <div id="mydiv$0">) and after much trial and error I am 90% sure it is causing a problem. The function just doesn't work. How would I fix this?

Also just a question regarding how the waitForKeyElements() function works. The site has a dropdown in which you select an option. Each option will load a table with the same ID's and classes, just different content.

Would the function recognize this new table loading?

Upvotes: 1

Views: 865

Answers (2)

Brock Adams
Brock Adams

Reputation: 93473

This is two questions, in one. The first was answered by Blender; you must escape the $ characters in the id.

So, for <div id="mydiv$0">, use something like:

waitForKeyElements ("#mydiv\\$0", yourActionFuntion);


The answer to the second question:

Each option will load a table with the same ID's and classes, just different content. Would the (waitForKeyElements) recognize this new table loading?

is: it depends.

Is the page completely deleting and re-adding the element? If so, then use waitForKeyElements() normally.

Is the page just changing the content of the element? Then the best approach varies on the circumstances but, in general, use an approach similar to the second part of this answer.

We need to see your target page, or an SSCCE, to say any more.

Upvotes: 1

Blender
Blender

Reputation: 298166

You have to escape the dollar sign:

$('#mydiv\\$0')

Upvotes: 2

Related Questions