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
|
// Edit result text button behaviour
|
||||||
function applyEditResultTextCallback() {
|
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 $result = $(this).closest('.result');
|
||||||
var $form = $(data.html);
|
var $form = $(data.html);
|
||||||
var $prevResult = $result;
|
var $prevResult = $result;
|
||||||
$result.after($form);
|
$result.after($form);
|
||||||
$result.remove();
|
$prevResult.hide();
|
||||||
|
|
||||||
formAjaxResultText($form);
|
formAjaxResultText($form, $prevResult);
|
||||||
|
|
||||||
// Cancel button
|
// Cancel button
|
||||||
$form.find('.cancel-edit').click(function() {
|
$form.find('.cancel-edit').click(function() {
|
||||||
$form.after($prevResult);
|
$prevResult.show();
|
||||||
$form.remove();
|
$form.remove();
|
||||||
applyEditResultTextCallback();
|
applyEditResultTextCallback();
|
||||||
TinyMCE.destroyAll();
|
TinyMCE.destroyAll();
|
||||||
|
@ -64,9 +64,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply ajax callback to form
|
// Apply ajax callback to form
|
||||||
function formAjaxResultText($form) {
|
function formAjaxResultText($form, $prevResult) {
|
||||||
$form.on('ajax:success', function(e, data) {
|
$form.on('ajax:success', function(e, data) {
|
||||||
var newResult;
|
var newResult;
|
||||||
|
if ($prevResult) $prevResult.remove();
|
||||||
$form.after(data.html);
|
$form.after(data.html);
|
||||||
newResult = $form.next();
|
newResult = $form.next();
|
||||||
initFormSubmitLinks(newResult);
|
initFormSubmitLinks(newResult);
|
||||||
|
|
|
@ -310,6 +310,10 @@
|
||||||
if (imageContainer === undefined) {
|
if (imageContainer === undefined) {
|
||||||
createImageHiddenField();
|
createImageHiddenField();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Small fix for ResultText when you cancel after change MarvinJS
|
||||||
|
if (imageContainer === undefined) return [];
|
||||||
|
|
||||||
imageContainer.value = JSON.stringify(images);
|
imageContainer.value = JSON.stringify(images);
|
||||||
return JSON.stringify(images);
|
return JSON.stringify(images);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue