Commit 92b7c569a7d3249968108afab3a7c32c0cdcbc8c
1 parent
fa323c0c
Exists in
master
and in
4 other branches
FIX: note-original-content appending itself too many times
Showing
1 changed file
with
8 additions
and
4 deletions
Show diff stats
app/assets/javascripts/notes.js
| @@ -233,10 +233,12 @@ var NoteList = { | @@ -233,10 +233,12 @@ var NoteList = { | ||
| 233 | form.show(); | 233 | form.show(); |
| 234 | 234 | ||
| 235 | var textarea = form.find("textarea"); | 235 | var textarea = form.find("textarea"); |
| 236 | - var p = $("<p></p>").text(textarea.val()); | ||
| 237 | - var hidden_div = $('<div class="note-original-content"></div>').append(p); | ||
| 238 | - form.append(hidden_div); | ||
| 239 | - hidden_div.hide(); | 236 | + if (form.find(".note-original-content").length === 0) { |
| 237 | + var p = $("<p></p>").text(textarea.val()); | ||
| 238 | + var hidden_div = $('<div class="note-original-content"></div>').append(p); | ||
| 239 | + form.append(hidden_div); | ||
| 240 | + hidden_div.hide(); | ||
| 241 | + } | ||
| 240 | textarea.focus(); | 242 | textarea.focus(); |
| 241 | }, | 243 | }, |
| 242 | 244 | ||
| @@ -532,6 +534,8 @@ var NoteList = { | @@ -532,6 +534,8 @@ var NoteList = { | ||
| 532 | note_text.html(response.note).show(); | 534 | note_text.html(response.note).show(); |
| 533 | 535 | ||
| 534 | var note_form = note_li.find(".note-edit-form"); | 536 | var note_form = note_li.find(".note-edit-form"); |
| 537 | + var original_content = note_form.find(".note-original-content"); | ||
| 538 | + original_content.remove(); | ||
| 535 | note_form.hide(); | 539 | note_form.hide(); |
| 536 | note_form.find(".btn-save").enableButton(); | 540 | note_form.find(".btn-save").enableButton(); |
| 537 | 541 |