2 var __bind = function (self, fn) {
3 return function() { fn.apply(self, arguments); };
7 $.widget("wl.search", {
14 console.log("dataType: " + this.options.dataType);
15 var url = this.element.data('source');
17 minLength: this.options.minLength,
18 select: __bind(this, this.enter),
19 focus: function() { return false; },
20 source: function(req, cb) {
24 success: function(data) {
27 error: function() { cb([]); }
33 this.element.autocomplete($.extend(opts, this.options))
34 .data("autocomplete")._renderItem = __bind(this, this.render_item);
37 enter: function(event, ui) {
38 if (ui.item.url != undefined) {
39 location.href = ui.item.url;
41 this.element.closest('form').submit();
45 render_item: function (ul, item) {
46 return $("<li></li>").data('item.autocomplete', item)
47 .append('<a href="'+item.url+'"><span class="search-hint-label">'+item.label+'</span>'+
48 '<span class="search-hint-category mono">'+item.category+'</span></a>')