如果我做“jquery sortable”在一个令人满意的项目上,我再也无法将鼠标聚焦在可疑文本中的任何位置 [英] If I do "jquery sortable" on a contenteditable item(s), I then can't focus mouse anywhere inside contenteditable text anymore
问题描述
奇怪的是,这只在Firefox和Opera中被破解(IE,Chrome和Safari可以正常工作)。
Strangely this is broken only in Firefox and Opera (IE, Chrome and Safari works as it should).
有关快速修复的建议吗?
Any suggestions for a quick fix?
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$('#sortable').sortable();
});
</script>
</head>
<body>
<span id="sortable">
<p contenteditable="true">One apple</p>
<p>Two pears</p>
<p>Three oranges</p>
</span>
</body>
</html>
推荐答案
我找到了另一个解决方案这个问题。
I have found another "solution" to this problem.
当声明你的可排序时,你应该添加一个取消:这样的选项:
When declaring your sortable, you should add a cancel: option like this:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$('#sortable').sortable({cancel: ':input,button,.contenteditable'});
});
</script>
</head>
<body>
<span id="sortable">
<p contenteditable="true" class="contenteditable">One apple</p>
<p>Two pears</p>
<p>Three oranges</p>
</span>
</body>
</html>
此版本不会在开始时强制使用光标,但也无法使用此字段进行拖动。我建议将< p>
包装在一个容器中,该容器有一些拖动句柄(就像gmail中每一行开头的点)。
This version does not force your cursor at the start, but you also can't drag using this field. I'd advice wrapping the <p>
in a container which has some sort of dragging handle (like the dots at the start of every row in gmail).
附注:':输入,按钮'
是必需的,因为这是默认选项。如果你不添加这些,你会遇到类似输入字段和按钮的问题。
side remark: ':input,button'
is required, because that is the default option. If you do not add these, you get similar problems with inputfields and buttons.
这篇关于如果我做“jquery sortable”在一个令人满意的项目上,我再也无法将鼠标聚焦在可疑文本中的任何位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!