Skip to content

Commit

Permalink
Disconnect examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
bezborodow committed Jun 20, 2018
1 parent 7f20aa1 commit 60014f7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test2.html
Expand Up @@ -17,6 +17,8 @@ <h2>We want every .initialize-me item to have color changed to blue by js - no m

<button id="add-outside">Add new item outside target element.</button>

<button id="stop-obs">Stop observing</button>

<hr>

<p>You can even add item with .initialize-me class via browser inspector - proper js will be executed on it just when you finish edition.</p>
Expand Down Expand Up @@ -48,16 +50,16 @@ <h2>We want every .initialize-me item to have color changed to blue by js - no m

$.initialize.defaults.target = document.getElementById('target-element');

$.initialize('.initialize-me', function() {
var obs1 = $.initialize('.initialize-me', function() {
$(this).css('color', 'blue');
});

$.initialize('.initialize-me span', function() {
var obs2 = $.initialize('.initialize-me span', function() {
$(this).css('background-color', 'blue');
$(this).css('color', 'white');
});

$.initialize('div + p', function() {
var obs3 = $.initialize('div + p', function() {
$(this).css('font-weight', 'bold');
}, { target: document.getElementById('sibling-test') });

Expand Down Expand Up @@ -86,6 +88,12 @@ <h2>We want every .initialize-me item to have color changed to blue by js - no m
.prependTo('#sibling-test');
});

$('#stop-obs').click(function(){
obs1.disconnect();
obs2.disconnect();
obs3.disconnect();
});

});

</script>
Expand Down

0 comments on commit 60014f7

Please sign in to comment.