Search code examples
javascriptjqueryjquery-uiaspect-ratiojquery-ui-resizable

Remove Aspect Ratio of Resizable Div Using Jquery


I have a simple div.

<div id="resize" style="border:1px solid black"></div>

I made it resizeable through Jquery UI Plugin. See code below:

var w = $('#resize').width();
var h = $('#resize').width();       

$('#resize').resizable({    
    animate: true,
    helper: 'ui-resizable-helper',
    aspectRatio:  w / h
});     

I want to remove its aspect ratio functionality in run time but still make it resizable. How will I do it?


Solution

  • in the api documentation there you can read that it could be set after initialization with

    var myValue = true;
    $( ".selector" ).resizable( "option", "aspectRatio", myValue );