2

Possible Duplicate:
Is there a jQuery DOM change listener?

there is a way to have a js function loaded or to call that function every time when dom is modified? I have a html page on which I expand another panel in the same page from an action button in this way the dom is modified and my js function is not called any more :|

Community
  • 1
  • 1
mcmwhfy
  • 1,654
  • 5
  • 36
  • 58
  • http://stackoverflow.com/questions/1091661/detect-element-content-changes-with-jquery http://stackoverflow.com/questions/2844565/is-there-a-jquery-dom-change-listener – bhb Oct 17 '12 at 08:21
  • No, but you could create a custom event and fire it every time you are done modifying the DOM. – Asad Saeeduddin Oct 17 '12 at 08:21
  • Working example to detect dom change - http://jsfiddle.net/eQErD/1/ – bhb Oct 17 '12 at 08:25
  • Please look ---------------> there are several – mplungjan Oct 17 '12 at 08:26
  • @bhb I use it in this way but not really working :( – mcmwhfy Oct 17 '12 at 08:56
  • can you please add the code to a fiddle. – bhb Oct 17 '12 at 09:04
  • @bhb I cannot because that function use a mega library called pie.js http://css3pie.com/ :| – mcmwhfy Oct 17 '12 at 09:48

1 Answers1

3

Code

$("#a").bind("DOMSubtreeModified", function() {
     if (window.PIE) {
        $(this).each(function() {
            PIE.attach(this);
        });
    }
    alert("tree changed");
});


$("#add").click(function() {
    $("#a").append("<span>hey there</span>");
});
​

HTML:

<div id="a"></div>
<button id="add">Add to Div</button>​

Working fiddle

bhb
  • 2,476
  • 3
  • 17
  • 32