Answer the question
In order to leave comments, you need to log in
jQuery ready for new elements?
By $(document).ready all select elements are processed .
After that, new selects can appear on the page, they can be created by javascript or received by ajax.
With live, you can assign some kind of event handler to them, but I need to handle them at the time of creation.
I cannot wedge into places where elements are created.
How to process new elements?
Answer the question
In order to leave comments, you need to log in
Try to do like this -
var nodes = document.getElementsByTagName('select');
var nodes = document.getElementsByTagName('select');
var prev = 0;
setInteval(function () {
if (nodes.length != prev) {
prev = nodes.length;
recount();
}
}, 10);
setInterval to check for availability.
“I can’t wedge into places where elements are created.” can you all?
As an option, override document.createElement and call your event after calling the old document.createElement. Then cling to this event and check what has been created there.
This needs to be checked for compatibility though, and may not work when elements are created via .innerHTML.
DOM Level 2 has a DOMSubtreeModified event, try hanging it on document
in modern browsers.
www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-mutationevents
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question