Bootstrap Suggest Search Suggestion Plugin Usage

This plugin needs to be seen after work.

First download the Bootstrap JS package. Add this plugin. Note that the CSS style is quoted and cannot be forgotten.

bootstrap suggest搜索建议插件使用详解

The front page code is done because the landlord is done different results. bootstrap suggest搜索建议插件使用详解

  Home   Works   Title:               
    in the result is the second The species, the request inside the plugin.
Function getSuggest (OBJ) {var testbssuggest = $ ("# title"). Bssuggest ({URL: "/ slide / loadselect ? Keyword = "+ Obj +" ", getDataMethod:" firstByURL ", // How to get data, URL: Once you have been requesting from URL; DATA: Getting from Options.Data; firstByurl: Get all data from URL, then Get Effectivefieldsalias: {Title: "Title"}, searchfields: ["Title", Keyfield: "Title", EffectiveFields: ["Title", EffectiveFields: True, // ShowHeader: True, // Display Header showbtn: true, // Does not display the drop-down button delayUntilKeyup: false, // Get the data is obtained as firstByURL, the data} is delayed when there is input / acquisition to the focus. on ('OnsetSelectValue', Function (E, Keyword) {var URL = ""; sWitch (OBJ) {CASE "1": URL = ""; Break; Case "2": URL = urljump (; Break; Case "3": URL = ""; Break;} $ URL "). VAL (URL + (0, - 1))));});}
Corresponding background code:
The result of the final page display.
   Take a look at the following configuration instructions can change different needs. 
#### Method call Disable prompt: $ (“INPUT # test”). Bssuggest (“disable”); Enable Tip: $ (“Input # test” .Bssuggest (“enable”); destruction plugin: $ (“Input # test”). Bssuggest (“Destroy”); View version: $ (“Input # test”). Bssuggest (“Version”); ### # Event Monitor OnDataRequestSuccess: When the AJAX request data is successfully triggered, then the result is sent to the second parameter onsetSelectValue: Trigger when the value is selected from the drop-down menu, and the set data is sent back to the second parameter onunsetSelectValue: When set up IDField, trigger (“# test”) .on (“# test”) .on (“# test”) .on (‘OnDatarEquestSuccess’, Function (Event, Result) {Console.log (Result);}) .on (‘OnSetSelectValue’, Function (E, Keyword) {Console.log (‘OnsetSelectValue:’, keyword);}) .on ‘OnunSetSelectValue’, Function (E) {Console.log (‘OnunSetSelectValue’);});

Configuration parameters

The value in the parameter list is the plugin default value
   VAR DEFAULTOPTIONS = {URL: NULL, // Request data URL address JSONP: NULL, // Set this parameter name The JSONP function will be turned on, otherwise use the JSON data structure Data: {value: []}, // Tips used, pay attention to the format indexid: 0, // Each set of data, as the DATA of the Input input box -ID, set to -1 and IDField does not set this value indexkey: 0, // Each set of data, as the content IDFIELD: '', / / ​​/ / / / // //, // Which field of each set of data As a Data-ID, the priority is higher than the indexid setting (recommended) keyfield: '', // which field of each set of data is used as the input box content, high priorityWhether to automatically select the value of the value allowyword: true, // if the value is allowed when the value is automatically selected, and // is allowed to request the data getDataMethod: 'firstDataMethod:' firstDataMethod: 'firstDATHOD:' firstDATBYURL ' // How to get data, the URL: It has been requested from the URL; DATA: Net from Options.Data; FirstByURL: Get all the data from the URL, then get DELAYUNTILKEYUP: FALSE, // Get data from Options.Data When FirstByURL is delayed, the data IgnoreCase: false, // front-end search match is delayed, whether the case is ignored EFFECTIELDS: [], // is valid to be displayed in the list, and the non-active field will be filtered, the default is all . EffectiveFieldsalias: {}, // Valid field alias object, used for the Show Searchfields: [], // valid search field, is used when searching data from the front end, but not necessarily displayed in the list. The EffectiveFields Configuration field is also used to search for filter TwowayMatch: true, // whether two-way matching search. To the True, the keyword is included or included. It is considered that the match is successful. If FALSE is entered, the keyword is included in the matching field, which means matching success multiword: false, // multi-keywords separated by symbol segmentation support Separe: ',' , // Multiple keywords support separator, default is a half-width comma / * ui * / autodropup: false, // select vegetablesWhether the single is automatically judged to expand up. Set to True, then the drop-down menu is high than the form, and the upward direction will not be overwritten by the form, the selection menu pops up the autominWidth: false: false, / / ​​whether the minimum width is set to FALSE, the minimum width is not smaller than the input box width Showheader: false, // Whether to display the Header of the selected list. When TRUE, the valid field is greater than one column, showing the head showbtn: true, // Whether to display the drop-down button inputbgcolor: ', // Enter the box background color, when with the container background color, the configuration INPUTWARNCOLOR: 'RGBA (255, 0, 0, .1)', // Enter the box content is not the drop-down list to select the warning color ListStyle: {'padding-top': 0, 'max-height': '375px', 'max -Width ':' 800px ',' overflow ':' auto ',' width ':' auto ',' transition ':' 0.3s ',' -Webkit-Transition ':' 0.3s ',' -Moz-Transition ':' 0.3s ','-transition ':' 0.3s '}, // list style control listAlign:' left ', // prompt list alignment location, Left / Right / Auto Listhoverstyle:' Background: # 07d; color: #fff ', // Tips Box List Mouse Suspension Style LISTHOVERCSS:' Jhover ', // Tips Box List Mouse Suspended Style Name Cleaable:False, // If you can clear the input content / * key * / keyleft: 37, // to the left direction key, the different operating systems may differ, then define the keyup: 38, // up the direction keys KeyRight: 39, / / ​​To the right direction key KeyDown: 40, // Down direction Keyenter: 13, // Enter key / * methods * / fnProcessData: processData, // Format data method, return data format reference DATA parameters FNGETDATA: GetData, // Get data method, no special needs generally do not set fnadjustajaxparam: null, // Adjust the AJAX request parameter method for more request configuration requirements. For further processing of requesting keyword, modify time-time, etc., for timeout, the input keyword is further handled further before the filter data is searched. Note that string} should be returned; 


The above is all the content of this article, I hope to help everyone, I hope everyone will support Tumi Cloud. bootstrap suggest搜索建议插件使用详解

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment