Skip to content

Commit

Permalink
oops: Fix Reset Button
Browse files Browse the repository at this point in the history
This addresses issue 3670 where the reset button does nothing but return
an error. This adds a check for `data-draft-id` to the reset button. If
there is one it will delete the draft and reset the text box. If there is
not one then it will just reset the text box.
Also includes:
- A line to add the `data-draft-id` to the text box automatically, when a
draft is saved, through AJAX.
  • Loading branch information
JediKev committed Jul 18, 2017
1 parent d2ef3b1 commit 6b639d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions js/redactor-osticket.js
Expand Up @@ -94,6 +94,7 @@ RedactorPlugins.draft = function() {
// No change yet — dont't show the button
return;
}
this.$box.find('textarea').attr('data-draft-id', this.opts.draftId);
if (data && this.code.get()) {
this.$draft_saved.show().delay(5000).fadeOut();
}
Expand Down Expand Up @@ -290,10 +291,10 @@ $(function() {
var reset = $('input[type=reset]', el.closest('form'));
if (reset) {
reset.click(function() {
if (el.hasClass('draft'))
el.redactor('deleteDraft');
if (el.attr('data-draft-id'))
el.redactor('draft.deleteDraft').attr('data-draft-id', '');
else
el.redactor('set', '', false, false);
el.redactor('insert.set', '', false, false);
});
}
$('input[type=submit]', el.closest('form')).on('click', function() {
Expand Down

0 comments on commit 6b639d6

Please sign in to comment.