I'd like to do something like this:
$('#myDiv').positionChanged(function() {
alert('Yay!');
});
Any ideas? Is this already built into jQuery in someway?
I'd like to do something like this:
$('#myDiv').positionChanged(function() {
alert('Yay!');
});
Any ideas? Is this already built into jQuery in someway?
I ended up using this:
function whereIChangePosition() {
// Code to change position
// ...
$('#myDiv').trigger('positionChanged');
}
And my listener:
$('#myDiv').bind('positionChanged', function() {
// Do stuff
});
unfortunately there is nothing of the kind in jquery. but that will be a good idea for maybe the next release.
So far what you can do is to add a call back yourself:
lets say you have a function that changes the position of a div.
function changePosition(elId,position) {
$(elId).css('top',position);
// or more complexe code
}
you can add a call back function to it.
function changePosition(elId,position,callback) {
$(elId).css('top',position);
callback();
}
The other method is to use DOMAttrModified event, but it has very low browser support as of this date