Unable to apply JqueryUI Resizable AspectRatio after initialization?

后端 未结 4 2001
生来不讨喜
生来不讨喜 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条回答
  •  灰色年华
    2021-02-14 12:47

    I don't know if it will work or what will happen. But you can try something like this.

    $(function(){
        var settings = {
            aspectRatio : .75  
        };
        $("#tadaa").resizable(settings);
    
        $("input").change(function(){
            if($(this).is(":checked"))
            {
    
                $("#tadaa").resizable( "destroy" );
                $("#tadaa").resizable();
            }
            else  
            {
                $("#tadaa").resizable( "destroy" );
                $("#tadaa").resizable(settings);
            }   
        });
    });
    

    Live demo, currently only the bottom draggable element is styled to use, horizontal div is not styled.

    http://jsfiddle.net/t6xFN/1/

提交回复
热议问题