scinote-web/app/assets/javascripts/experiments/show.js
ajugo 80f66736b6
Add new task modal for experiment table view [SCI-7448] (#4638)
* Add new task modal for experiment table view [SCI-7448]

* Fix placeholder and size of the icon [SCI-7448]

* Reload experiment table [SCI-7448]
2022-11-24 14:49:42 +01:00

30 lines
974 B
JavaScript

(function() {
function initNewMyModuleModal() {
let experimentWrapper = '.experiment-new-my_module';
let newMyModuleModal = '#new-my-module-modal';
// Modal's submit handler function
$(experimentWrapper)
.on('ajax:success', newMyModuleModal, function() {
$(newMyModuleModal).modal('hide');
})
.on('ajax:error', newMyModuleModal, function(ev, data) {
$(this).renderFormErrors('my_module', data.responseJSON);
});
$(experimentWrapper)
.on('ajax:success', '.new-my-module-button', function(ev, data) {
// Add and show modal
$(experimentWrapper).append($.parseHTML(data.html));
$(newMyModuleModal).modal('show');
$(newMyModuleModal).find("input[type='text']").focus();
// Remove modal when it gets closed
$(newMyModuleModal).on('hidden.bs.modal', function() {
$(newMyModuleModal).remove();
});
});
}
initNewMyModuleModal();
}());