2 var __bind = function (self, fn) {
3 return function() { fn.apply(self, arguments); };
7 $.widget("wl.search", {
14 minLength: this.options.minLength,
15 select: __bind(this, this.enter),
16 focus: function() { return false; },
17 source: this.element.data('source'),
20 this.element.autocomplete($.extend(opts, this.options))
21 .data("autocomplete")._renderItem = __bind(this, this.render_item);
24 enter: function(event, ui) {
25 if (ui.item.url != undefined) {
26 location.href = ui.item.url;
28 this.element.closest('form').submit();
32 render_item: function (ul, item) {
33 return $("<li></li>").data('item.autocomplete', item)
34 .append('<a href="'+item.url+'"><span class="search-hint-label">'+item.label+'</span>'+
35 '<span class="search-hint-category mono">'+item.category+'</span></a>')