I'm trying to use Jquery-Mutation Summary https://code.google.com/p/mutation-summary/ "a JavaScript library that makes observing changes to the DOM fast, easy and safe"
It can be found here: https://github.com/joelpurra/jquery-mutation-summary
Here's an example of it at work: http://joelpurra.github.io/jquery-mutation-summary/example/demo.html
All I want to do is call a function when there's changes to content within an element such as a div with an id "MyDiv"
Here's my code. What am I doing wrong? There is no alert message as my function that's being called in this example is suppose to display once changes are observed.
<script src="http://joelpurra.github.io/jquery-mutation-summary/lib/mutation-summary /src/mutation-summary.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://joelpurra.github.io/jquery-mutation-summary/src/jquery.mutation- summary.js"></script>
<script>
function MyFunction(){
alert('changes have been made');
}
// This code won't be executed until jQuery has been loaded.
$(function() {
var $ChangeThere = $("#MyDiv")
// The callback in this case will only print the result
// Connect mutation-summary
$ChangeThere.mutationSummary("connect", callback, [{
all: true
}]);
// Disconnect when done listening
//$ChangeThere.mutationSummary("disconnect");
function callback(summaries) {
MyFunction();
}
});
</script>