是否有可能使p
元素的内容可编辑和JQuery UI可排序?做一个p元素的内容可编辑和JQuery UI可排序
在我下面的简单示例中,p
元素是可排序的,但不能编辑它们的文本。无论如何要克服这一点?
注意我曾尝试在容器嵌套p
的,使得容器可排序且p
是可编辑的,但我仍然无法编辑内p
。
$(document).ready(function() {
\t $(".elements").sortable({
\t connectWith: ".elements"
\t });
});
p {
\t height: 100px;
\t background-color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="../dist/js/visual-designer.min.js"></script>
<div class="elements">
\t <p id="foo" contenteditable="true">Foo. Help! I can be sorted but cannot be edited.</p>
\t
\t <!-- Even if I nest p's in a container they still are not editable -->
\t <div class="test-container">
\t \t <p id="bar" contenteditable="true">Bar. Help! I can be sorted but cannot be edited.</p>
\t </div>
</div>
试图从这里得到一些帮助。 https://stackoverflow.com/a/14745046/7844349 –