1

我想要resize一个可调整大小、可拖动的图像document.ready

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

开始演示: http: //jsfiddle.net/8VY52/
$('#image').width(50); :http : //jsfiddle.net/8VY52/141/

是否有resize必须触发的事件?

4

1 回答 1

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/

于 2013-10-23T19:36:01.387 回答