I was wondering if there was any unobtrusive way to hook into methods such as attr, data, css, etc and call custom triggers?
Ideally, I could do something like this:
$(".friend a").bind("attr.changed", changed /* data */, function(e) {
alert("The " + changed.attribute + " attribute changed from " + changed.from + " to " + changed.to + "!");
});
$(".friend").append(
$("<a/>").
attr("href", "#").
html("Friend 1").
click(function() { alert('I was clicked!'); }); // creates the element, doesn't execute since element didn't exist
$(".friends a").each(function() {
var $this = $(this);
$this.attr("rel", "friend"); // triggers "attr.changed"
});
Ideally this would be able to be triggered on any element and pass the attr changed, from and to in an object to the trigger call from inside each jQuery method.