[英]Disable Sortable option
How can I disable sorting using the javascript from https://github.com/RubaXa/Sortable temporarily? 如何暂时使用https://github.com/RubaXa/Sortable中的javascript禁用排序?
see this jsfiddle example . 看到这个jsfiddle的例子 。 that's how it's set up:
这就是它的设置方式:
$('ul').each(function( index ) {new Sortable(this, { group: "sortgroup" });
});
You could try to give the constructor handle -parameter. 你可以尝试给构造函数handle -parameter。
$('ul').each(function( index ) {
new Sortable(this, { group: "sortgroup", handle: ".someClass"});
});
Sort happends when user clicks element containing that class. 当用户单击包含该类的元素时对事件进行排序。 Instructions here .
这里的说明 。
The dev version , which will be released in December 2014, introduces a sort: <Boolean>
option. dev版本将于2014年12月发布,它引入了一个
sort: <Boolean>
选项。 Setting it to false
disables the ability to sort the list. 将其设置为
false
将禁用对列表进行排序的功能。 This is useful if you want to have a "source" list, from which you can drag elements into a "destination" list, but don't want to sort elements in the source list. 如果您想要一个“源”列表,从中可以将元素拖到“目标”列表中,但不希望对源列表中的元素进行排序,这将非常有用。
Check out the demo - http://rubaxa.github.io/Sortable/#ag 看看演示 - http://rubaxa.github.io/Sortable/#ag
Standalone non-sortable list demo: http://jsbin.com/sevofa/1/edit?html,js,output 独立的不可排序列表演示: http : //jsbin.com/sevofa/1/edit? html,js, output
var sortable = new Sortable(document.getElementsByClassName('sortable')[0], { group: 'foo', sort: false, animation: 150 }); switcher.onchange = function () { var on = switcher.sort.value == 1; sortable.option('sort', on); };
<script src="https://rawgit.com/RubaXa/Sortable/dev/Sortable.js"></script> <form id="switcher"> sort: <label><input checked name="sort" value="0" type="radio"/> false</label> <label><input name="sort" value="1" type="radio"/> true</label> </form> <ul class="list-group sortable"> <li class="list-group-item">This is <a href="http://rubaxa.github.io/Sortable/">Sortable</a></li> <li class="list-group-item">It works with Bootstrap...</li> <li class="list-group-item">...out of the box.</li> <li class="list-group-item">It has support for touch devices.</li> <li class="list-group-item">Just drag some elements around.</li> </ul>
This is using the html5 draggable attr. 这是使用html5 draggable attr。 You can simply disable it.
你可以简单地禁用它。
$('#items li').attr('draggable', 'false')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.