[jQuery] insertBefore not inserting into dom?

[jQuery] insertBefore not inserting into dom?


Hi,
I'm trying to insert a new list item, but when I do it seems that
jquery does not recognize that the new item is in there and jquery
functions don't work on it. An example is below:
<script type="text/javascript">
$(document).ready(
function () {
$("#windowOpen").click(function(){
var z = "<li id=\"row_45\" class=\"row_full
sortableitem\"><button class=\"in_dom\" id=\"btn_45\" value=\"click me
\">NEW click me</button></li>";
$(z).insertBefore("#row_2");
});
$(".in_dom").click(function(){
alert("that's in the dom");
});
});
</script>
<button id="windowOpen" value="fuckyeah">show div</button>
<ul id="orderedlist">
<li id="row_1" class="row_full sortableitem"><button
class="in_dom" id="btn_1" value="click me">click me</button></li>
<li id="row_2" class="row_full sortableitem"><button
class="in_dom" id="btn_2" value="click me">click me</button></li>
<li id="row_3" class="row_full sortableitem"><button
class="in_dom" id="btn_3" value="click me">click me</button></li>
<li id="row_4" class="row_full sortableitem"><button
class="in_dom" id="btn_4" value="click me">click me</button></li>
</ul>
** When #row_45 is inserted, the .in_dom button does not work on click
Any help on this would be greatly appreciated. Thanks all!
-Scott
































    • Topic Participants

    • scott