src/grid-filter.js
function (item) {
            // Check if it already exists in the suggestions list.  Duplicates aren't allowed.
            var exists = false;
            for(var j = 0; j < suggestions.length; j++){
              if(suggestions[j].attr('name').toLowerCase() === item.name.toLowerCase()){
                exists=true;
                break;
              }
            }
            // If it didn't exist, add it to the list of suggestions and the searchTerms.
            if(!exists){
              suggestions.push(item);
            }

            // We are using searchTerms's setter to execute the filter, so have to set the property (not just update):
            var searchTerms = self.viewModel.attr('searchTerms').attr().concat(item.name);
            self.viewModel.attr('searchTerms', searchTerms);
          }
function (item) {
            // Check if it already exists in the suggestions list.  Duplicates aren't allowed.
            var exists = false;
            for(var j = 0; j < suggestions.length; j++){
              if(suggestions[j].attr('name').toLowerCase() === item.name.toLowerCase()){
                exists=true;
                break;
              }
            }
            // If it didn't exist, add it to the list of suggestions and the searchTerms.
            if(!exists){
              suggestions.push(item);
            }

            // We are using searchTerms's setter to execute the filter, so have to set the property (not just update):
            var searchTerms = self.viewModel.attr('searchTerms').attr().concat(item.name);
            self.viewModel.attr('searchTerms', searchTerms);
          }
function ( item ) { // Check if it already exists in the suggestions list.  Duplicates aren't allowed. var exists = false ; for ( var j = 0 ; j < suggestions . length ; j ++ ) { if ( suggestions [ j ] . attr ( 'name' ) . toLowerCase ( ) === item . name . toLowerCase ( ) ) { exists = true ; break ; } } // If it didn't exist, add it to the list of suggestions and the searchTerms. if ( ! exists ) { suggestions . push ( item ) ; } // We are using searchTerms's setter to execute the filter, so have to set the property (not just update): var searchTerms = self . viewModel . attr ( 'searchTerms' ) . attr ( ) . concat ( item . name ) ; self . viewModel . attr ( 'searchTerms' , searchTerms ) ; }
onAdd is used to maintain the suggestion dropdown box and the searchTerms in the scope.
It is called internally by the jquery.tokenInput plugin when either the enter key
is pressed in the input box or a selection is made in the suggestions dropdown.
onAdd is used to maintain the suggestion dropdown box and the searchTerms in the scope . It is called internally by the jquery . tokenInput plugin when either the enter key is pressed in the input box or a selection is made in the suggestions dropdown .