Buy now!

NinjaSuggest

The NinjaSuggest plugin transforms a select element into a suggest component.

References

Add those references into your website:

                        
                        
                        
                        

                        
                        
                        
                    

And the plugin files:

                        
                        
                    

Call ninjaSuggest method to initialize the plugin:

                        $(document).ready(function(){
                            $("#myElement").ninjaSuggest({options});
                        });
                    

Options


ninjaSuggest({
    url: null,                                  //-- set an ajax method
    model: null,                                //-- set a model as initial filter
    key: null,                                  //-- set the key property to be used
    text: null,                                 //-- set the name of the property to be used as text or a function to return a custom text
    minChars: 2,                                //-- set the minimum amount of characters to trigger the ajax method
    maxChars: 5,                                //-- set the maximum amount of characters to trigger the ajax method
    onSelect: function(item) { },               //-- set a funtion to be executed on item selected

    clearNoMatches: true,                       //-- set if the input will be cleared on blur if no matchs founded,
    limitTo: 5,                                 //-- set the search limit. Use 0 to show all items
    defaultPlaceholder: "Search for...",        //-- default text for placeholder inside search input.
    noMatchFoundText: "No item founded.",       //-- default text for no matches founded.
    filterType: 'anywhere'                      //-- 'anywhere' or 'startwith'
});
                        

Methods

Name

Description

Sample

ninjaSuggest({options})

Initialize the plugin to the specified selector.

$("#mySelect").ninjaSuggest()