Initialize scripts on dom event handler

pull/279/head
Halil İbrahim Kalkan 7 years ago
parent f2e0bc669f
commit d1aa3973c8

@ -11,10 +11,10 @@
var confirmText = $form.attr('data-confirm');
if (confirmText) {
$form.submit(function(e) {
$form.submit(function (e) {
if (!$form.data('abp-confirmed')) {
e.preventDefault();
abp.message.confirm(confirmText).done(function(accepted) {
abp.message.confirm(confirmText).done(function (accepted) {
if (accepted) {
$form.data('abp-confirmed', true);
$form.submit();
@ -32,6 +32,25 @@
}
}
function initializeScript($el) {
$el.findWithSelf('[data-script-class]').each(function () {
var scriptClassName = $(this).attr('data-script-class');
if (!scriptClassName) {
return;
}
var scriptClass = eval(scriptClassName);
if (!scriptClass) {
return;
}
var scriptObject = new scriptClass();
$el.data('abp-script-object', scriptObject);
scriptObject.initDom && scriptObject.initDom($el);
});
}
abp.dom.onNodeAdded(function (args) {
args.$el.findWithSelf('[data-toggle="tooltip"]').tooltip({
container: 'body'
@ -42,6 +61,8 @@
});
enableFormFeatures(args.$el.findWithSelf('form'), true);
initializeScript(args.$el);
});
abp.dom.onNodeRemoved(function (args) {

Loading…
Cancel
Save