I'm trying to make small windows which are draggable and have editable divs inside using contentEditable=true.
I can drag them around but cant edit the text
$(document).ready(function(){
$('#mybtn').click(function(){
$('#container').append("<div class=window><div class=bar>Story Element</div><div contentEditable=true class=textbox>Drag me</div></div>");
$(".window").draggable({delay: 100});
});
$(".textbox").on("click", function(e) {
$(".window").draggable('disable');
$(this).find(".textbox").focus();
});
$(".textbox").on("blur", function(){
$(".window").draggable('enable');
});
});
您没有正确包装要附加的内容的属性。请尝试:
$('#container').append("<div class='window'><div class='bar'>Story Element</div><div contentEditable='true' class='textbox'>Drag me</div></div>");
If you make make the 'bar' class a handle for draggable, it looks like it acts how you want it to. You can drag the box around and still edit the text.
$(".window").draggable({handle:'.bar'});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.