admin管理员组文章数量:1430346
How can I disable sorting using the javascript from temporarily?
see this jsfiddle example. that's how it's set up:
$('ul').each(function( index ) {new Sortable(this, { group: "sortgroup" });
});
How can I disable sorting using the javascript from https://github./RubaXa/Sortable temporarily?
see this jsfiddle example. that's how it's set up:
$('ul').each(function( index ) {new Sortable(this, { group: "sortgroup" });
});
Share
Improve this question
edited Nov 12, 2014 at 7:51
Dr.Kameleon
22.8k21 gold badges124 silver badges237 bronze badges
asked May 8, 2014 at 7:59
user3159270user3159270
1292 silver badges10 bronze badges
2 Answers
Reset to default 2You could try to give the constructor 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. Setting it to false
disables the ability to sort the list. 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
Standalone non-sortable list demo: http://jsbin./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./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>
本文标签: javascriptDisable Sortable optionStack Overflow
版权声明:本文标题:javascript - Disable Sortable option - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745537934a2662357.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论