Is it possible to make a p
element both content editable AND JQuery UI Sortable?
In my simple example below, the p
elements are sortable but you cannot edit their text. Is there anyway to overcome this?
Note I have tried nesting p
's in containers so that the container is sortable and the p
is editable but I still cannot edit the inner p
.
$(document).ready(function() {
$( ".elements" ).sortable({
connectWith: ".elements"
});
});
p {
height: 100px;
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">
<p id="foo" contenteditable="true">Foo. Help! I can be sorted but cannot be edited.</p>
<!-- Even if I nest p's in a container they still are not editable -->
<div class="test-container">
<p id="bar" contenteditable="true">Bar. Help! I can be sorted but cannot be edited.</p>
</div>
</div>