I need to be able to dynamically create <select>
element and turn it into jQuery .combobox()
. This should be element creation event, as opposed to some "click" event in which case I could just use jQuery .on()
.
So does something like this exist?
$(document).on("create", "select", function() {
$(this).combobox();
}
I'm reluctant to use livequery, because it's very outdated.
UPDATE The mentioned select/combobox is loaded via ajax into a jQuery colorbox (modal window), thus the problem - I can only initiate combobox using colorbox onComplete
, however on change of one combobox another select/combobox must be dynamically created, therefor I need a more generic way to detect creation of an element (select
in this case).
UPDATE2 To try and explain the problem further - I have select/combobox
elements created recursively, there is also a lot of initiating code inside .combobox()
, therefore if I used a classic approach, like in @bipen's answer, my code would inflate to insane levels. Hope this explains the problem better.
UPDATE3 Thanks everyone, I now understand that since deprecation of DOMNodeInserted
there is a void left in DOM mutation and there is no solution to this problem. I'll just have to rethink my application.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…