jQuery UI Resizable: set size programmatically?

后端 未结 3 850

For example, user inputs width and height values to tell the widget to resize to that dimension. How to implement this?

3条回答
  •  醉梦人生
    2021-01-15 11:05

    I use for this following code:

    function resize(target, new_width, new_height){ 
        var $wrapper = $(target).resizable('widget'),
            $element = $wrapper.find('.ui-resizable'),
            dx = $element.width()  - new_width,
            dy = $element.height() - new_height;
    
        $element.width( new_width );
        $wrapper.width( $wrapper.width() - dx );
        $element.height( new_height );
        $wrapper.height( $wrapper.height() - dy );
    }
    

提交回复
热议问题