Resizable: options stop event vs resizestop event?
So I'm trying to do the following:
- Create new div
- Make div draggable and resizable
- Add new div to container
- Trigger resizable "stop" event to set some values that would be normally set when resizing
I'm using something like this code:
- var resizableOptions = {
- handles: "n,e,s,w,se,sw,ne,nw",
- containment: 'parent',
- stop: function(ev, ui) {
- console.log('resizing stopped');
- ui.element.data('mywidth', ui.size.width);
- }
- };
- var $newDiv = $('<div id="mydiv"></div>');
- $newDiv
- .draggable(draggableOptions)
- .resizable(resizableOptions)
- .appendTo('#container')
- .trigger('resizestop');
(Just assume that draggableOptions is also defined)
What happens here is that resizestop is not fired at all. If I try $('#mydiv').trigger('resizestop') in Firebug it doesn't fire either. However, if I bind the stop event like this:
- $newDiv
- .draggable(draggableOptions)
- .resizable(resizableOptions) //stop function removed from resizableOptions
- .on('resizestop', function(ev, ui) { //do same stuff as previous code })
- .appendTo('#container')
- .trigger('resizestop');
Then "resizestop" event can be fired programmatically, but it complains that ui is not defined, which would suggest that there is a difference to the "stop" event and "resizestop" events.
Can anyone help me figure out what is happening here and why there is a difference between defining the event in options vs as a separate event handler?