nl_tokens: single
pl_tokens: function ( ) { var val , triggerChange = false , data = null , self = this , oldData = this . data ( ) ; if ( arguments . length === 0 ) { return this . opts . element . val ( ) ; } val = arguments [ 0 ] ; if ( arguments . length > 1 ) { triggerChange = arguments [ 1 ] ; } if ( this . select ) { this . select . val ( val ) . find ( ":selected" ) . each2 ( function ( i , elm ) { data = self . optionToData ( elm ) ; return false ; } ) ; this . updateSelection ( data ) ; this . setPlaceholder ( ) ; if ( triggerChange ) { this . triggerChange ( { added : data , removed : oldData } ) ; } } else { // val is an id. !val is true for [undefined,null,'',0] - 0 is legal if ( ! val && val !== 0 ) { this . clear ( triggerChange ) ; return ; } if ( this . opts . initSelection === undefined ) { throw new Error ( "cannot call val() if initSelection() is not defined" ) ; } this . opts . element . val ( val ) ; this . opts . initSelection ( this . opts . element , function ( data ) { self . opts . element . val ( ! <mask> ? "" : self . id ( data ) ) ; self . updateSelection ( data ) ; self . setPlaceholder ( ) ; if ( triggerChange ) { self . triggerChange ( { added : data , removed : oldData } ) ; } } ) ; } }