admin管理员组文章数量:1393061
I am creating a list & want to make its item sortable and editable. So i am doing it like this:
<ul id="ul_list">
<li><span contenteditable="true">A</span></li>
<li><span contenteditable="true">B</span></li>
<li><span contenteditable="true">C</span></li>
</ul>
$("#ul_list").sortable();
/
But if i use jquery ui sortable then my list item is losing focus for editing and that's why i am not able to edit them.
So please suggest how can i do this?
I am creating a list & want to make its item sortable and editable. So i am doing it like this:
<ul id="ul_list">
<li><span contenteditable="true">A</span></li>
<li><span contenteditable="true">B</span></li>
<li><span contenteditable="true">C</span></li>
</ul>
$("#ul_list").sortable();
http://jsfiddle/7jzVa/
But if i use jquery ui sortable then my list item is losing focus for editing and that's why i am not able to edit them.
So please suggest how can i do this?
Share Improve this question asked Sep 27, 2013 at 21:01 PeeyushPeeyush 4,86817 gold badges66 silver badges92 bronze badges 1- stackoverflow./questions/2995329/… gives a good solution~ – CoolGuy Commented Jan 17, 2014 at 2:32
3 Answers
Reset to default 4We could make use of the cancel option provided by jquery sortable
$("#ul_list").sortable({cancel: 'span'});
#ul_list li{
border:1px solid red;
list-style-type:none;
}
<ul id="ul_list">
<li><span contenteditable="true">A</span></li>
<li><span contenteditable="true">B</span></li>
<li><span contenteditable="true">C</span></li>
</ul>
Clicking on the text will make it editable. Can be sorted by clicking anywhere else
Finally i did it like this;
On mousedown event i applied the sortable() so that user can sort elements by dragging them,
On click i destroyed the sortable .sortable("destroy"). So now the elements are editable.
I also have the same problem and I fixed by the following code:
$('#ul_list').on("mousedown",function(){
$("#ul_list").sortable();
});
本文标签: javascriptjQuery UI sortable amp contenteditabletrue not working togetherStack Overflow
版权声明:本文标题:javascript - jQuery UI sortable & contenteditable=true not working together - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744718547a2621553.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论