Opened 14 years ago

Closed 6 years ago

Last modified 6 years ago

#4186 closed bug (fixed)

Resizable: aspectRatio cannot be changed after initialization

Reported by: tcarnell Owned by: Scott González
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

Change History (14)

comment:1 Changed 14 years ago by tcarnell

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

$("#myResizable")....

comment:2 Changed 14 years ago by rdworth

Milestone: TBD1.6
Priority: majorcritical

comment:3 Changed 14 years ago by Scott González

Milestone: 1.71.next
Priority: criticalblocker

comment:4 Changed 14 years ago by rbrackett

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;
		}
	};
})();

comment:5 Changed 13 years ago by kunderez

Yep, it still exists in 1.8.1 :/

comment:6 Changed 12 years ago by Scott González

Milestone: 1.next1.9

comment:7 Changed 12 years ago by Scott González

Priority: blockermajor

comment:8 Changed 12 years ago by rdworth

#7117 is a duplicate of this ticket.

comment:9 Changed 12 years ago by odyniec

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;
        }
    };
})();

comment:10 Changed 10 years ago by Scott González

Milestone: 1.9.02.0.0

comment:11 Changed 10 years ago by tj.vantoll

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

comment:12 Changed 10 years ago by tj.vantoll

#5208 is a duplicate of this ticket.

comment:13 Changed 6 years ago by Scott González

Keywords: aspectRatio resizable option init removed
Milestone: 2.0.01.12.2
Resolution: fixed
Status: openclosed
Last edited 6 years ago by Ryan J Ollos (previous) (diff)

comment:14 Changed 6 years ago by Scott González

Owner: set to Scott González

In c481400f:

Resizable: Fix aspectRatio cannot be changed after initialization.

Fixes #4186
Closes gh-1750

Note: See TracTickets for help on using tickets.