jquery ui resizable custom handle error

2020-05-06 10:44发布

问题:

Im trying to get a custom handle work with jquery ui resizable widget, but when I use the handles option to pass in a jquery reference to another element, it fails. From what Iv read from the documentation and other examples on the web, this should work just fine.

<div class="layer">
<div class="left">left</div>
<div class="center">center</div>
<div class="right">right</div>
</div>
​
$('.layer').resizable({
    handles: {
        'e': $('.right')
    }
});
​

Here's a fiddle: http://jsfiddle.net/MatteS75/3dwVp/

回答1:

I found a workaround.

By setting the handles option to null, and setting the classes myself, I got my custom handle to work. This required some investigation in the jquery ui code to figure out.

<div class="layer" style="width: 150px;">
<div class="left">left</div>
<div class="center">center</div>
<div class="right ui-resizable-handle ui-resizable-e">right</div>
</div>
​
$('.layer').resizable({
    handles: null
});
​

http://jsfiddle.net/MatteS75/3dwVp/7/

However, I do think this is a jquery ui bug, releated to this question: overriding a jquery ui widget string option with an object



回答2:

This is a bug that has been fixed very recently:

http://bugs.jqueryui.com/ticket/8713

https://github.com/jquery/jquery-ui/commit/9b908878ae3a9c0fbbd9958b579f223a648c5c69