简体   繁体   中英

jQuery UI Selectables - Start Drag-Selecting from Outside of Objects

I am using the jQuery UI Slectable http://jqueryui.com/demos/selectable/

Once initialized (just like in the demo on that link). drag-selecting only works if I start holding the mouse button on top of a object. If I start drag-selecting from outside of the objects, the selecting does not work.

Is there any way to enable it so the user can initiate the drag-selecting outside of the Selectable objects?

The mouse event listener in the 'selectable' is bound to the wrapper element that you have attached it to. By attaching the it to the body and providing a filter you can get what you're looking for.

Based on the jQuery example:

$('body').selectable({ filter: '#selectable li' });

*Edit: Unfortunately because of this._trigger("stop", event); it will stop other events on the page.

Your best solution might be to just make the wrapper around the selectables larger.*

This behaviour is already happening, you just can't see it!

Simply adjust the css for your ul.selectable so that it properly contains the floated li 's.

#selectable{
    overflow: hidden;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM