Reputation: 133
I have tried over and over but i just can seem to get the text to be editable and also draggable, because when i apply .draggable() the contenteditable="true" becomes "false".
Javascript
$(".note").keyup(function() {
$(this).css('height' , '100%');
});
HTML
<div class="note" contenteditable="true">
<span id='close' onclick='this.parentNode.parentNode.removeChild(this.parentNode)'>
<img src="images/close.png" height="30" width="30" align="right" style="vertical-align: top; float: right"/>
</span>
</div>
CSS
.note {
width: 280px;
height: 130px;
padding-top: 20px;
margin-top: 60px;
margin-left: 25px;
padding: 2;
word-break: break-word;
font-family: Note;
font-size: 20px;
background-image: url("images/stickynote.png");
background-repeat: no-repeat;
background-size: cover;
z-index: 1;
}
Upvotes: 0
Views: 152
Reputation: 3304
You can do this to make it so if you double click it will be editable, but single clicks will drag it.
$(".note").draggable()
.click(function() {
$(this).draggable( {disabled: false});
}).dblclick(function() {
$(this).draggable({ disabled: true });
});
Add this to the close buttons <img>
code will keep it in the top right of your container:
position: relative;
top: -20px;
Upvotes: 1