Hi,
onmatch will fire for a particular entwine definition when the entwine selector becomes the most specific selector that matches for any particular element
onunmatch will fire for a particular entwine definition when the entwine _was_ the most specific selector that matched for a particular element (and so onmatch was called) but now it isn't any more
In this case adding a "test" class does not affect the most specific rule for the button element - the button still matches the "button" selector, and there is no other selector that is more specific that it also matches.
If you added a more specific rule that _does_ match .test, like so, then you'd see the button onunmatch and the button.test onmatch get called when adding the class, and the button onmatch and the button.test onunmatch get called when removing the class:
$('button.test').entwine({
onmatch: function(){
console.log('test match: ', this);
},
onunmatch: function(){
console.log('test unmatch: ', this);
}
});
There is also onadd and onremove, which are called when an element is first added to the DOM and when the element is removed from the DOM. This doesn't take into account any changes after being added to the DOM (so the element's classes and other attributes which affect which entwine selector get used must be set before adding to the DOM), but is often what people actually want.
Hamish Friedlander