@@ -554,6 +554,45 @@ var ts = (function (exports, $) {
554
554
}
555
555
}
556
556
557
+ class AjaxDestroy extends Parser {
558
+ parse ( node ) {
559
+ let instances = node . _ajax_attached ;
560
+ if ( instances !== undefined ) {
561
+ for ( let instance of instances ) {
562
+ if ( instance . destroy !== undefined ) {
563
+ instance . destroy ( ) ;
564
+ } else {
565
+ console . warn ( 'ts.ajax bound but no destroy method defined: ' + instance . constructor . name ) ;
566
+ }
567
+ }
568
+ }
569
+ let attrs = this . node_attrs ( node ) ;
570
+ if ( attrs [ 'ajax:bind' ] ) {
571
+ let evts = attrs [ 'ajax:bind' ] ;
572
+ $ ( node ) . off ( evts ) ;
573
+ }
574
+ if ( window . bootstrap ) {
575
+ let dd = window . bootstrap . Dropdown . getInstance ( node ) ;
576
+ let tt = window . bootstrap . Tooltip . getInstance ( node ) ;
577
+ if ( dd ) {
578
+ dd . dispose ( ) ;
579
+ }
580
+ if ( tt ) {
581
+ tt . dispose ( ) ;
582
+ }
583
+ }
584
+ $ ( node ) . empty ( ) ;
585
+ $ ( node ) . off ( ) ;
586
+ $ ( node ) . removeData ( ) ;
587
+ node = null ;
588
+ }
589
+ }
590
+ function ajax_destroy ( elem ) {
591
+ elem = elem instanceof $ ? elem . get ( 0 ) : elem ;
592
+ let handle = new AjaxDestroy ( ) ;
593
+ handle . walk ( elem ) ;
594
+ }
595
+
557
596
class Overlay extends Events {
558
597
constructor ( opts ) {
559
598
super ( ) ;
@@ -569,7 +608,7 @@ var ts = (function (exports, $) {
569
608
}
570
609
compile ( ) {
571
610
compile_template ( this , `
572
- <div class="modal fade ${ this . css } " id="${ this . uid } " t-elem="elem" data-bs-backdrop="static ">
611
+ <div class="modal ${ this . css } " id="${ this . uid } " t-elem="elem">
573
612
<div class="modal-dialog">
574
613
<div class="modal-content">
575
614
<div class="modal-header">
@@ -589,17 +628,16 @@ var ts = (function (exports, $) {
589
628
$ ( 'body' ) . addClass ( 'modal-open' ) ;
590
629
this . container . append ( this . elem ) ;
591
630
this . elem . show ( ) ;
592
- this . elem . modal ( 'show' ) ;
593
631
this . is_open = true ;
594
632
this . trigger ( 'on_open' ) ;
595
633
}
596
634
close ( ) {
597
635
if ( $ ( '.modal:visible' ) . length === 1 ) {
598
636
$ ( 'body' ) . removeClass ( 'modal-open' ) ;
599
637
}
600
- this . elem . modal ( 'hide' ) ;
601
- this . elem . remove ( ) ;
638
+ ajax_destroy ( this . elem ) ;
602
639
this . is_open = false ;
640
+ this . elem . removeData ( 'overlay' ) . remove ( ) ;
603
641
this . trigger ( 'on_close' ) ;
604
642
}
605
643
}
@@ -1190,38 +1228,6 @@ var ts = (function (exports, $) {
1190
1228
}
1191
1229
}
1192
1230
}
1193
- class AjaxDestroy extends Parser {
1194
- parse ( node ) {
1195
- let instances = node . _ajax_attached ;
1196
- if ( instances !== undefined ) {
1197
- for ( let instance of instances ) {
1198
- if ( instance . destroy !== undefined ) {
1199
- instance . destroy ( ) ;
1200
- } else {
1201
- console . warn ( 'ts.ajax bound but no destroy method defined: ' + instance . constructor . name ) ;
1202
- }
1203
- }
1204
- }
1205
- let attrs = this . node_attrs ( node ) ;
1206
- if ( attrs [ 'ajax:bind' ] ) {
1207
- let evts = attrs [ 'ajax:bind' ] ;
1208
- $ ( node ) . off ( evts ) ;
1209
- }
1210
- node . _ajax_attached = null ;
1211
- let dd = bootstrap . Dropdown . getInstance ( node ) ;
1212
- let tt = bootstrap . Tooltip . getInstance ( node ) ;
1213
- if ( dd ) {
1214
- dd . dispose ( ) ;
1215
- }
1216
- if ( tt ) {
1217
- tt . dispose ( ) ;
1218
- }
1219
- $ ( node ) . empty ( ) ;
1220
- $ ( node ) . off ( ) ;
1221
- $ ( node ) . removeData ( ) ;
1222
- node = null ;
1223
- }
1224
- }
1225
1231
class AjaxHandle extends AjaxUtil {
1226
1232
constructor ( ajax ) {
1227
1233
super ( ) ;
@@ -1241,8 +1247,7 @@ var ts = (function (exports, $) {
1241
1247
context ;
1242
1248
if ( mode === 'replace' ) {
1243
1249
let old_context = $ ( selector ) ;
1244
- this . destroy ( old_context . children ( ) ) ;
1245
- old_context . empty ( ) ;
1250
+ this . destroy ( old_context ) ;
1246
1251
old_context . replaceWith ( payload ) ;
1247
1252
context = $ ( selector ) ;
1248
1253
if ( context . length ) {
0 commit comments