mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-17 14:46:00 +08:00
30 lines
967 B
JavaScript
30 lines
967 B
JavaScript
(function() {
|
|
function initNewMyModuleModal() {
|
|
let experimentWrapper = '#experiment-canvas';
|
|
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();
|
|
}());
|