Problem with jQuery sorting / disabling

I have a problem with my jQuery sort list where the text is selected. I found a function disableSelection(), but cannot make it work.

Here js:

$('ul#current_projects').sortable({
placeholder: "drop-zone",
axis: 'y',
handle: 'span.handle',
opacity: 0.5,
revert: true  
});

$('ul#current_projects').disableSelection();

Here's the HTML:

<ul id="current_projects" class="ui-sortable" unselectable="on">
  <li class="project_42">
    <div class="command">
      <span class="handle"></span>
      <a href="#" class="delete"></a>
    </div>
    <a href="#" class="project">Testing</a>
  </li>
  <li class="project_52">
    <div class="command">
      <span class="handle"></span>
      <a href="#" class="delete"></a>
    </div>
    <a href="#" class="project">Testing</a>
  </li>
</ul>

The nonselectable state appears to be enabled, but just does not prevent text selection.

Any help would be appreciated

+3
source share
1 answer

I had a similar problem and it worked for me when I used the parameter containment: 'parent'.

Try:

$('ul#current_projects').sortable({
 placeholder: "drop-zone",
 axis: 'y',
 handle: 'span.handle',
 opacity: 0.5,
 revert: true,
 containment: 'parent'
}).disableSelection();
+3
source

Source: https://habr.com/ru/post/1784590/


All Articles