mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Renders entire template when add the first note or delete the last
This commit is contained in:
41
js/script.js
41
js/script.js
@@ -299,10 +299,14 @@ View.prototype = {
|
|||||||
|
|
||||||
self._notes.load(id);
|
self._notes.load(id);
|
||||||
self._notes.removeActive().done(function () {
|
self._notes.removeActive().done(function () {
|
||||||
$(".notes-grid").isotope('remove', note.parent())
|
if (self._notes.length == 0) {
|
||||||
.isotope('layout');
|
$(".notes-grid").isotope('remove', note.parent())
|
||||||
self.showAll();
|
.isotope('layout');
|
||||||
self.renderNavigation();
|
self.showAll();
|
||||||
|
self.renderNavigation();
|
||||||
|
} else {
|
||||||
|
self.render();
|
||||||
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
alert('Could not delete note, not found');
|
alert('Could not delete note, not found');
|
||||||
});
|
});
|
||||||
@@ -384,18 +388,23 @@ View.prototype = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
self._notes.create(note).done(function() {
|
self._notes.create(note).done(function() {
|
||||||
note = self._notes.getActive();
|
if (self._notes.length > 1) {
|
||||||
var $notehtml = $("<div class=\"note-grid-item\">" +
|
note = self._notes.getActive();
|
||||||
"<div class=\"quicknote noselect\" style=\"background-color:" + note.color + "\" data-id=\"" + note.id + "\">" +
|
var $notehtml = $("<div class=\"note-grid-item\">" +
|
||||||
"<div id='title-editable' class='note-title'>" + note.title + "</div>" +
|
"<div class=\"quicknote noselect\" style=\"background-color:" + note.color + "\" data-id=\"" + note.id + "\">" +
|
||||||
"<button class=\"icon-delete hide-delete-icon icon-delete-note\" title=\"Delete\"></button>" +
|
"<div id='title-editable' class='note-title'>" + note.title + "</div>" +
|
||||||
"<div id='content-editable' class='note-content'>" + note.content + "</div>" +
|
"<button class=\"icon-delete hide-delete-icon icon-delete-note\" title=\"Delete\"></button>" +
|
||||||
"</div></div>");
|
"<div id='content-editable' class='note-content'>" + note.content + "</div>" +
|
||||||
$(".notes-grid").prepend( $notehtml )
|
"</div></div>");
|
||||||
.isotope({ filter: '*'})
|
$(".notes-grid").prepend( $notehtml )
|
||||||
.isotope( 'prepended', $notehtml);
|
.isotope({ filter: '*'})
|
||||||
self._notes.unsetActive();
|
.isotope( 'prepended', $notehtml);
|
||||||
self.renderNavigation();
|
self._notes.unsetActive();
|
||||||
|
self.renderNavigation();
|
||||||
|
} else {
|
||||||
|
self._notes.unsetActive();
|
||||||
|
self.render();
|
||||||
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
alert('Could not create note');
|
alert('Could not create note');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user