@@ -53,8 +53,8 @@ define([
5353 pageThis : null , // target's page object
5454 id : '' , // target id
5555 value : null , // pre-defined value
56- finish : null , // callback after selection
57- select : null , // callback after selection from suggestInput
56+ finish : null , // callback after selection (value, dtype)
57+ select : null , // callback after selection from suggestInput (value, dtype)
5858 allowDataType : null ,
5959 // additional options
6060 classes : '' ,
@@ -175,59 +175,63 @@ define([
175175 _bindAutocomplete ( varList ) {
176176 let that = this ;
177177
178- $ ( com_util . formatString ( ".vp-ds-box-{0} input.vp-ds-target" , that . uuid ) ) . autocomplete ( {
179- autoFocus : true ,
180- minLength : 0 ,
181- source : function ( req , res ) {
182- var srcList = varList ;
183- var returlList = new Array ( ) ;
184- for ( var idx = 0 ; idx < srcList . length ; idx ++ ) {
185- // srcList as object array
186- if ( srcList [ idx ] . label . toString ( ) . toLowerCase ( ) . includes ( req . term . trim ( ) . toLowerCase ( ) ) ) {
187- returlList . push ( srcList [ idx ] ) ;
178+ try {
179+ $ ( com_util . formatString ( ".vp-ds-box-{0} input.vp-ds-target" , that . uuid ) ) . autocomplete ( {
180+ autoFocus : true ,
181+ minLength : 0 ,
182+ source : function ( req , res ) {
183+ var srcList = varList ;
184+ var returlList = new Array ( ) ;
185+ for ( var idx = 0 ; idx < srcList . length ; idx ++ ) {
186+ // srcList as object array
187+ if ( srcList [ idx ] . label . toString ( ) . toLowerCase ( ) . includes ( req . term . trim ( ) . toLowerCase ( ) ) ) {
188+ returlList . push ( srcList [ idx ] ) ;
189+ }
188190 }
189- }
190- res ( returlList ) ;
191- } ,
192- select : function ( evt , ui ) {
193- let result = true ;
194- // trigger change
195- $ ( this ) . val ( ui . item . value ) ;
196- $ ( this ) . data ( 'type' , ui . item . dtype ) ;
197-
198- that . state . filterType = 'All' ;
199- that . state . data = ui . item . value ;
200- that . state . dataType = ui . item . dtype ;
201- that . state . returnDataType = ui . item . dtype ;
202-
203- that . prop . pageThis . state [ that . prop . id ] = ui . item . value ;
204- that . prop . pageThis . state [ that . prop . id + '_state' ] = that . state ;
205-
206- // select event
207- if ( that . prop . select && typeof that . prop . select == 'function' ) {
208- result = that . prop . select ( ui . item . value , ui . item . dtype ) ;
209- }
210- $ ( this ) . trigger ( 'change' ) ;
191+ res ( returlList ) ;
192+ } ,
193+ select : function ( evt , ui ) {
194+ let result = true ;
195+ // trigger change
196+ $ ( this ) . val ( ui . item . value ) ;
197+ $ ( this ) . data ( 'type' , ui . item . dtype ) ;
198+
199+ that . state . filterType = 'All' ;
200+ that . state . data = ui . item . value ;
201+ that . state . dataType = ui . item . dtype ;
202+ that . state . returnDataType = ui . item . dtype ;
203+
204+ that . prop . pageThis . state [ that . prop . id ] = ui . item . value ;
205+ that . prop . pageThis . state [ that . prop . id + '_state' ] = that . state ;
206+
207+ // select event
208+ if ( that . prop . select && typeof that . prop . select == 'function' ) {
209+ result = that . prop . select ( ui . item . value , ui . item . dtype ) ;
210+ }
211+ $ ( this ) . trigger ( 'change' ) ;
211212
212- if ( result != undefined ) {
213- return result ;
213+ if ( result != undefined ) {
214+ return result ;
215+ }
216+ return true ;
217+ } ,
218+ search : function ( evt , ui ) {
219+ return true ;
214220 }
215- return true ;
216- } ,
217- search : function ( evt , ui ) {
218- return true ;
219- }
220- } ) . focus ( function ( ) {
221- $ ( this ) . select ( ) ;
222- $ ( this ) . autocomplete ( 'search' , $ ( this ) . val ( ) ) ;
223- } ) . click ( function ( ) {
224- $ ( this ) . select ( ) ;
225- $ ( this ) . autocomplete ( 'search' , $ ( this ) . val ( ) ) ;
226- } ) . autocomplete ( 'instance' ) . _renderItem = function ( ul , item ) {
227- return $ ( '<li>' ) . attr ( 'data-value' , item . value )
228- . append ( `<div class="vp-sg-item">${ item . label } <label class="vp-gray-text vp-cursor"> | ${ item . dtype } </label></div>` )
229- . appendTo ( ul ) ;
230- } ;
221+ } ) . focus ( function ( ) {
222+ $ ( this ) . select ( ) ;
223+ $ ( this ) . autocomplete ( 'search' , $ ( this ) . val ( ) ) ;
224+ } ) . click ( function ( ) {
225+ $ ( this ) . select ( ) ;
226+ $ ( this ) . autocomplete ( 'search' , $ ( this ) . val ( ) ) ;
227+ } ) . autocomplete ( 'instance' ) . _renderItem = function ( ul , item ) {
228+ return $ ( '<li>' ) . attr ( 'data-value' , item . value )
229+ . append ( `<div class="vp-sg-item">${ item . label } <label class="vp-gray-text vp-cursor"> | ${ item . dtype } </label></div>` )
230+ . appendTo ( ul ) ;
231+ } ;
232+ } catch ( ex ) {
233+ vpLog . display ( VP_LOG_TYPE . ERROR , ex ) ;
234+ }
231235 }
232236
233237 _bindEventForPopup ( ) {
0 commit comments