jQuery可调整大小的触发器调整大小

时间:2013-10-23 19:29:07

标签: javascript jquery jquery-ui jquery-ui-resizable

我希望在resizedocument.ready $('#image').width(50);可调整大小的可拖动图像。

问题在于,如果我改变图像的宽度,其余的可调整大小/可拖动将会被破坏。

开始演示:http://jsfiddle.net/8VY52/
resizehttp://jsfiddle.net/8VY52/141/

是否有必须触发的{{1}}事件?

1 个答案:

答案 0 :(得分:3)

为什么不在文档准备好后调整图像大小然后应用可调整大小的函数:

$('#draggableHelper').draggable();

$(function(){
    $('#image').width(50);
    $('#image').resizable();
});

示例:http://jsfiddle.net/8VY52/145/

如果你想在按钮点击事件上执行此操作,这是一个工作示例:

$('#draggableHelper').draggable();

$(function(){
    $('#image').width(50);
    $('#image').resizable();

    $('#resize-button').on('click',function(){
        var size = 150; //Or what ever you want
        $('#image').resizable('destroy');
        $('#image').width(size);
        $('#image').resizable();
    });

});

http://jsfiddle.net/8VY52/147/

相关问题