0
I’m finishing creating a WYSIWYG, but I have a problem with the text box.
When clicking on the icon referring to the text box, a onClick
which creates the text box, which is created with a div
editable - contenteditable="true"
(had problems with the textarea
).
My problem is: By clicking the icon again, I need it to create another text box instead of simply deleting the current one.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
function ctexto() {
document.getElementById("editavel").innerHTML =
'<div class="ui-widget-content, draggable">Arrastar<div id="divv" class="" contenteditable="true" >Este é um texto de teste</div></div>';
$(".draggable")
.draggable()
.click(function(){
if ( $(this).is('.ui-draggable-dragging') ) {
return;
}
$(this).draggable( "option", "disabled", true );
$(this).attr('contenteditable','true');
$(this).attr('resizable','false');
})
.blur(function(){
$(this).draggable( 'option', 'disabled', false);
$(this).attr('contenteditable','false');
});
}
</script>
<input type="button" onClick="ctexto()" value="Texto">
<div name="editavel" id="editavel"></div>
</body>
</html>
This code here is a little poorly adapted, but should give to understand the script.