mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 12:43:06 +08:00
Update MArvinJS asset on result text cancel
This commit is contained in:
parent
126c29ab12
commit
859c5931a4
2 changed files with 10 additions and 5 deletions
|
@ -40,18 +40,18 @@
|
|||
|
||||
// Edit result text button behaviour
|
||||
function applyEditResultTextCallback() {
|
||||
$('.edit-result-text').on('ajax:success', function(e, data) {
|
||||
$('.edit-result-text').off().on('ajax:success', function(e, data) {
|
||||
var $result = $(this).closest('.result');
|
||||
var $form = $(data.html);
|
||||
var $prevResult = $result;
|
||||
$result.after($form);
|
||||
$result.remove();
|
||||
$prevResult.hide();
|
||||
|
||||
formAjaxResultText($form);
|
||||
formAjaxResultText($form, $prevResult);
|
||||
|
||||
// Cancel button
|
||||
$form.find('.cancel-edit').click(function() {
|
||||
$form.after($prevResult);
|
||||
$prevResult.show();
|
||||
$form.remove();
|
||||
applyEditResultTextCallback();
|
||||
TinyMCE.destroyAll();
|
||||
|
@ -64,9 +64,10 @@
|
|||
}
|
||||
|
||||
// Apply ajax callback to form
|
||||
function formAjaxResultText($form) {
|
||||
function formAjaxResultText($form, $prevResult) {
|
||||
$form.on('ajax:success', function(e, data) {
|
||||
var newResult;
|
||||
if ($prevResult) $prevResult.remove();
|
||||
$form.after(data.html);
|
||||
newResult = $form.next();
|
||||
initFormSubmitLinks(newResult);
|
||||
|
|
|
@ -310,6 +310,10 @@
|
|||
if (imageContainer === undefined) {
|
||||
createImageHiddenField();
|
||||
}
|
||||
|
||||
// Small fix for ResultText when you cancel after change MarvinJS
|
||||
if (imageContainer === undefined) return [];
|
||||
|
||||
imageContainer.value = JSON.stringify(images);
|
||||
return JSON.stringify(images);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue