jQuery DOM and script tags
When an element contains script tags, and the element gets moved/modified, the script is fired twice. Is there any way to fix this issue without modifying the contents of script tags? We have customers who may add script to their CRM and would be beyond my control. I have included an example of the issue. Note that this can occur in wrapAll, sortable, and anything else which directly modifies the dom.
Test Sample : Copy this into a htm and correct the paths to the js files. You will see that the alert() fires before the 2nd content div is drawn and then again after the div containing the script is moved. Afterwards the script doesn't fire again.
<head>
<title></title>
<script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.7.2.custom.min.js" type="text/javascript"></script>
<script src="Scripts/ui.sortable.js" type="text/javascript"></script>
</head>
<body>
<div class="container">
<div class="content">Drag ME!
<script type="text/javascript">
alert("HIT");
</script></div>
<div class="content">Drag ME</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$(".container").sortable();
});
</script>
</body>