Unable to apply JqueryUI Resizable AspectRatio after initialization?

后端 未结 4 2106
生来不讨喜
生来不讨喜 2021-02-14 11:55

I was trying to turn the aspect ratios on/off dynamically in JQueryUI resizable, however even after setting the option to false, it keeps maintaining the aspect ratio. Below is

4条回答
  •  萌比男神i
    2021-02-14 12:26

    Another solution is to save resizable options in a variable and destroy and reinitialize the widget with the updated options:

    var options = $("#resizable").resizable("options");
    if (ischecked) {
        options.aspectRatio = .75;
    } else {
        options.aspectRatio = false;
    }
    $("#resizable").resizable("destroy");
    $("#resizable").resizable(options);
    

提交回复
热议问题