Skip to content

Commit cb7ee55

Browse files
committed
update
1 parent 2124b9f commit cb7ee55

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

public/assets/backend/js/dialog/bootstrap-dialog.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251
autodestroy: true,
252252
draggable: false,
253253
animate: true,
254+
enableScript: false,
254255
description: '',
255256
tabindex: -1
256257
};
@@ -660,7 +661,28 @@
660661
updateMessage: function () {
661662
if (this.isRealized()) {
662663
var message = this.createDynamicContent(this.getMessage());
664+
var scripts = [];
665+
if(this.options.enableScript){
666+
var $h=$(message);
667+
scripts=$h.find('script');
668+
$h.find('script').remove();
669+
message=$h.html();
670+
}
663671
this.getModalBody().find('.' + this.getNamespace('message')).html('').append(message);
672+
console.dir(scripts)
673+
if(scripts && scripts.length>0){
674+
var scriptText = '';
675+
for(var i=0;i<scripts.length;i++){
676+
var script=scripts[i];
677+
if(script.src){
678+
if($('script[src$="'+script.src+'"]').length<1) $('body').append('<script type="text/javascript" src="'+script.src+'"></script>');
679+
}else if(script.text){
680+
scriptText+='<script type="text/javascript">'+script.text+'</script>';
681+
}
682+
}
683+
if(scriptText) this.getModalBody().data('script-text',scriptText);
684+
}
685+
664686
}
665687

666688
return this;
@@ -1174,7 +1196,12 @@
11741196
});
11751197
this.getModal().on('shown.bs.modal', {dialog: this}, function (event) {
11761198
var dialog = event.data.dialog;
1177-
dialog.isModalEvent(event) && typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog);
1199+
if(dialog.isModalEvent(event)){
1200+
if(dialog.getModalBody().data('script-text')){
1201+
$('body').append(dialog.getModalBody().data('script-text'));
1202+
}
1203+
typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog);
1204+
}
11781205
});
11791206
this.getModal().on('hide.bs.modal', {dialog: this}, function (event) {
11801207
var dialog = event.data.dialog;

0 commit comments

Comments
 (0)