According to http://www.quirksmode.org/dom/events/resize.html the resize event is available on the window, but not on the document or other elements (if we ignore some exceptions mentioned at that page).
So it is really unexpectable that changing width and/or height of some element using resizable() causes:
1) resize event firing at all
2) resize event bubbling up to the window object
If I want to make only $('#elem') resizable, that's all I want. Not any bubbling or window resize event firing.
I made a one line change to the example fiddle (and updated the libraries a bit more recent versions):
http://jsfiddle.net/CPUwW/56/
// The following line is the needed change. widgetEventPrefix is
// originally 'resize'. It have to be changed.
$.ui.resizable.prototype.widgetEventPrefix = 'myresize';
$(function(){
var resizes = 0;
$(window).on('resize', function(){
$('#text').text(++resizes);
});
$('#my_element').resizable();
});
EDIT: The problem in other solutions on this page (and also here) is that bubbling up to the window and firing the window's resize event causes unnecessary overhead if you just want to resize some div or so.
EDIT2: Because widgetEventPrefix
is an internal parameter, it's name can change, it can be removed and it's behavior can be changed in new releases of jQuery UI. So, when upgrading UI, check that this works like before.