@@ -117,6 +117,7 @@ const SearchApp = {
117117 appKey : uuid ( ) ,
118118 shouldTeleport : false ,
119119 teleportTarget : null ,
120+ onClearCallback : null
120121 } ;
121122 } ,
122123 methods : {
@@ -155,7 +156,10 @@ const SearchApp = {
155156 } ,
156157
157158 removeAll : function ( ) {
158- this . components = [ ]
159+ this . components = [ ] ;
160+ if ( this . onClearCallback && typeof this . onClearCallback === 'function' ) {
161+ this . onClearCallback ( ) ;
162+ }
159163 } ,
160164 removeItem ( index ) {
161165 let idx = this . components . findIndex ( el => el . index == index ) ;
@@ -193,6 +197,9 @@ const SearchApp = {
193197 this . teleportTarget = null ;
194198 }
195199 } ,
200+ registerClearCallback ( callback ) {
201+ this . onClearCallback = callback ;
202+ }
196203 } ,
197204 mounted ( ) {
198205 console . info ( "Search mounted!" ) ;
@@ -911,7 +918,7 @@ const SearchLookupInput = {
911918 }
912919} ;
913920
914- const createMyApp = ( root , callback ) => {
921+ const createMyApp = ( root , callback , clearCallback ) => {
915922 if ( window . _search . app ) {
916923 window . _search . app . unmount ( ) ;
917924 delete window . _search . app ;
@@ -945,7 +952,10 @@ const createMyApp = (root, callback) => {
945952 window . _search . rootElemId = root ;
946953 const mountElement = document . getElementById ( root ) ;
947954 if ( mountElement ) {
948- app . mount ( '#' + root ) ;
955+ const instance = app . mount ( '#' + root ) ;
956+ if ( clearCallback ) {
957+ instance . registerClearCallback ( clearCallback ) ;
958+ }
949959 window . _search . app = app ;
950960 } else {
951961 console . warn ( `Mount element #${ root } not found` ) ;
0 commit comments