본문 바로가기

IT/javascript

jquery typeahead

http://www.runningcoder.org/jquerytypeahead/

 

jQuery Typeahead Search Configuration

Configure jQuery Typeahead Search plugin, learn about the options and what they can do to improve your search bar.

www.runningcoder.org

주요 설정부분은

val

display

dynamic: true

source

filter: true (default)

If set to false, Typeahead will skip any kind of filtering. This option is useful if you already filter the results in Backend.

If set to function, every element will be filtered using this custom rule.

WARNING accent, correlativeTemplate, offset and matcher will be skipped

// item: The matched item (object)
// displayKey: The matched item display key (string)
filter: function (item, displayKey) {
    if (item.name === "Typeahead") {
        return undefined;
    } else if (/hello/.test(displayKey)) {
        return false;
    } else if (item.name === "hi") {
        // return modified item object
        item.name = "new name key";
        return item;
    }
    return true;
}
 
// return undefined to skip to next item
// return false to attempt the matching function on the next displayKey
// return true to add the item to the result list
// return item object to modify the item and add it to the result list

 

callback: {

  onClickAfter: function (node, a, item, event) {

  }

}

'IT > javascript' 카테고리의 다른 글

javascript 에서 replace  (0) 2021.09.26