mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-24 15:54:00 +08:00
Enable result comment button after canceling result edit [SCI-6537] (#3894)
* Enable result comment button after cancelling edit button [SCI-6537]
This commit is contained in:
parent
3df030b29e
commit
493c7d64eb
3 changed files with 13 additions and 11 deletions
|
@ -35,18 +35,18 @@
|
|||
}
|
||||
|
||||
function applyEditResultAssetCallback() {
|
||||
$('.edit-result-asset').on('ajax:success', function(e, data) {
|
||||
$('.edit-result-asset').off('ajax:success ajax:error').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();
|
||||
|
||||
_formAjaxResultAsset($form);
|
||||
_formAjaxResultAsset($form, $prevResult);
|
||||
|
||||
// Cancel button
|
||||
$form.find('.cancel-edit').click(function () {
|
||||
$form.after($prevResult);
|
||||
$prevResult.show();
|
||||
$form.remove();
|
||||
applyEditResultAssetCallback();
|
||||
Results.toggleResultEditButtons(true);
|
||||
|
@ -60,8 +60,9 @@
|
|||
});
|
||||
}
|
||||
|
||||
function _formAjaxResultAsset($form) {
|
||||
function _formAjaxResultAsset($form, $prevResult) {
|
||||
$form.on('ajax:success', function(e, data) {
|
||||
if ($prevResult) $prevResult.remove();
|
||||
$form.after(data.html);
|
||||
var $newResult = $form.next();
|
||||
initFormSubmitLinks($newResult);
|
||||
|
|
|
@ -41,9 +41,10 @@
|
|||
}
|
||||
|
||||
// Apply ajax callback to form
|
||||
function _formAjaxResultTable($form) {
|
||||
function _formAjaxResultTable($form, $prevResult) {
|
||||
$form.on('ajax:success', function(e, data) {
|
||||
var $result;
|
||||
if ($prevResult) $prevResult.remove();
|
||||
$form.after(data.html);
|
||||
$result = $(this).next();
|
||||
initFormSubmitLinks($result);
|
||||
|
@ -64,20 +65,20 @@
|
|||
|
||||
// Edit result table button behaviour
|
||||
function applyEditResultTableCallback() {
|
||||
$('.edit-result-table').on('ajax:success', function(e, data) {
|
||||
$('.edit-result-table').off('ajax:success ajax:error').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();
|
||||
|
||||
_formAjaxResultTable($form);
|
||||
_formAjaxResultTable($form, $prevResult);
|
||||
_initEditableHandsOnTable($form);
|
||||
_onSubmitExtractTable($form);
|
||||
|
||||
// Cancel button
|
||||
$form.find('.cancel-edit').click(function () {
|
||||
$form.after($prevResult);
|
||||
$prevResult.show();
|
||||
$form.remove();
|
||||
applyEditResultTableCallback();
|
||||
Results.toggleResultEditButtons(true);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
// Edit result text button behaviour
|
||||
function applyEditResultTextCallback() {
|
||||
$('.edit-result-text').off().on('ajax:success', function(e, data) {
|
||||
$('.edit-result-text').off('ajax:success ajax:error').on('ajax:success', function(e, data) {
|
||||
var $result = $(this).closest('.result');
|
||||
var $form = $(data.html);
|
||||
var $prevResult = $result;
|
||||
|
|
Loading…
Reference in a new issue