1

I have a draggable canvas. I need to place a handler which is somewhere outside the div containing the canvas.

This is a canvas code:

<canvas width="700" height="500" class="ui-draggable" style="width: 450px; top: 257px; left: 200px;"></canvas>
Michal Olszowski
  • 795
  • 1
  • 8
  • 25
  • Can u be more specific and provide some code ? It's really hard to help you with that lack of informations... – Michal Olszowski May 21 '15 at 10:31
  • You may have a look at [this](http://stackoverflow.com/a/5744492/4202224) answer. A handle outside the element which is initialised in the `draggable`-widget is not possible. Refer to the [docs](http://api.jqueryui.com/draggable/#option-handle) for further informatuion. – empiric May 21 '15 at 10:52

1 Answers1

0

There is a selector handle

Type: Selector or Element
Default: false
Restricts sort start click to the specified element.

Code examples:
Initialize the sortable with the handle option specified:

$( ".selector" ).sortable({
    handle: ".handle"
});

See my JSFiddle for a live example. The elements can only be dragged by the orange handles that I have defined and created.

This is the case for all jQuery UI methods which use handles.

Josh Stevenson
  • 895
  • 5
  • 17
  • 1. He talks about `draggable` not `sortable`, 2. From the jQuery-UI docs: `Only elements that descend from the draggable element are permitted` so his requirement that the element should be outside the container can not be fullfilled – empiric May 21 '15 at 10:49
  • I know but all handles are going to be the same regardless of the method. It doesn't matter that it has to be a descendant of the element either. That doesn't mean it has to *physically* be a descendant on the screen. You just set the z-index to be higher than the parent and position the element with css. – Josh Stevenson May 21 '15 at 10:56
  • @empiric see http://jsfiddle.net/Panomosh/aezujdth/1/ the handles are children of the `li` in terms of HTML, but that doesn't mean they have to look that way on the page. – Josh Stevenson May 21 '15 at 11:00
  • Yes, it would work this way (see the Link to the answer I posted underneath the question). You could've mentioned that in your answer. Anyway the requirement of the OP is not clear, not your fault of course – empiric May 21 '15 at 11:03
  • Oh yeah. Sorry man, didn't see you'd posted that. Didn't mean to be patronising – Josh Stevenson May 21 '15 at 11:06