Skip to main content

Search and Top Navigation

#4186 closed bug (fixed)

Opened February 19, 2009 12:06PM UTC

Closed September 28, 2016 03:56PM UTC

Last modified September 28, 2016 10:01PM UTC

Resizable: aspectRatio cannot be changed after initialization

Reported by: tcarnell Owned by: scottgonzalez
Priority: major Milestone: 1.12.2
Component: ui.resizable Version: 1.6rc6
Keywords: Cc:
Blocked by: Blocking:
Description

I have a resizable div, and want to change the 'aspectRatio' behaviour on the fly. Attempting the following code has no affect:

$("#myResizable).resizable('option', 'aspectRatio', newState);

(where 'newState' is either true|false)

The workaround is as follows, but I am concerned about the cost overhead:

$("#myResizable).resizable('destroy');
//re-initialize the resizable with the desired 'aspectRatio' value
Attachments (0)
Change History (14)

Changed February 19, 2009 12:07PM UTC by tcarnell comment:1

(sorry) missed a closing double quote on the code samples above, should have been:

$("#myResizable")....

Changed February 20, 2009 01:00PM UTC by rdworth comment:2

milestone: TBD1.6
priority: majorcritical

Changed February 20, 2009 01:48PM UTC by scottgonzalez comment:3

milestone: 1.71.next
priority: criticalblocker

Changed May 13, 2009 12:11AM UTC by rbrackett comment:4

I just ran into this issue myself. Here's a quick workaround if someone needs it (probably not the right way to really patch it, though):

(function() {
	// Work around http://dev.jqueryui.com/ticket/4186
	var oldSetData = $.ui.resizable.prototype._setData;
	$.ui.resizable.prototype._setData = function(key, value) {
		oldSetData.apply(this, arguments);
		if (key === "aspectRatio") {
			this._aspectRatio = !!value;
		}
	};
})();

Changed May 14, 2010 11:09AM UTC by kunderez comment:5

Yep, it still exists in 1.8.1 :/

Changed October 19, 2010 03:19PM UTC by scottgonzalez comment:6

milestone: 1.next1.9

Changed October 19, 2010 04:09PM UTC by scottgonzalez comment:7

priority: blockermajor

Changed June 07, 2011 09:16AM UTC by rdworth comment:8

#7117 is a duplicate of this ticket.

Changed June 25, 2011 12:26AM UTC by odyniec comment:9

An updated workaround for recent versions of jQuery UI:

(function() {
    var oldSetOption = $.ui.resizable.prototype._setOption;
    $.ui.resizable.prototype._setOption = function(key, value) {
        oldSetOption.apply(this, arguments);
        if (key === "aspectRatio") {
            this._aspectRatio = !!value;
        }
    };
})();

Changed October 11, 2012 02:49PM UTC by scottgonzalez comment:10

milestone: 1.9.02.0.0

Changed October 28, 2012 01:57AM UTC by tj.vantoll comment:11

status: newopen
summary: changing aspectRatio of resizable using 'option' feature after init does not workResizable: aspectRatio cannot be changed after initialization

Verified that this is still an issue in 1.9.1 - http://jsfiddle.net/tj_vantoll/L4h3F/.

Related: #3423, #6723

Changed November 01, 2012 01:08AM UTC by tj.vantoll comment:12

#5208 is a duplicate of this ticket.

Changed September 28, 2016 03:56PM UTC by rjollos comment:13

_comment0: Fixed in [https://github.com/jquery/jquery-ui/commit/c481400f222c871ba5853bc2930a3b8b4375d08b c481400f222c871ba5853bc2930a3b8b4375d08b].1475100083254522
keywords: aspectRatio resizable option init
milestone: 2.0.01.12.2
resolution: → fixed
status: openclosed

Changed September 28, 2016 10:01PM UTC by scottgonzalez comment:14

owner: → scottgonzalez

In [changeset:"c481400f222c871ba5853bc2930a3b8b4375d08b" c481400f]:

#!CommitTicketReference repository="" revision="c481400f222c871ba5853bc2930a3b8b4375d08b"
Resizable: Fix aspectRatio cannot be changed after initialization.

Fixes #4186
Closes gh-1750