Problem with suggest as mixed mode file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global window, define, jQuery */ | |
(function(factory) { | |
"function" == typeof define && define.amd ? define('suggest', ['jquery', 'jquery-ui'], factory) : factory(jQuery) | |
})(function(jQuery, jQueryUi) { | |
console.log('yeah'); | |
function initialize() { | |
// Change back to the old behavior of auto-complete | |
// http://jqueryui.com/docs/Upgrade_Guide_184#Autocomplete | |
jQuery.ui.autocomplete.prototype._renderItem = function( ul, item ) { | |
return jQuery( "<li></li>" ) | |
.data( "item.autocomplete", item ) | |
.append( "<a>" + item.label + "</a>" ) | |
.appendTo( ul ); | |
}; | |
var req = false; | |
jQuery('.tx-solr-q').autocomplete({ | |
source: function(request, response) { | |
if (req) { | |
req.abort(); | |
response(); | |
} | |
req = jQuery.ajax({ | |
url: tx_solr_suggestUrl, | |
dataType: 'json', | |
data: { | |
termLowercase: request.term.toLowerCase(), | |
termOriginal: request.term, | |
L: jQuery('div.tx-solr input[name="L"]').val() | |
}, | |
success: function(data) { | |
req = false; | |
var rs = [], | |
output = []; | |
jQuery.each(data, function(term, termIndex) { | |
output.push({ | |
label : term.replace(new RegExp('(?![^&;]+;)(?!<[^<>]*)(' + | |
jQuery.ui.autocomplete.escapeRegex(request.term) + | |
')(?![^<>]*>)(?![^&;]+;)', 'gi'), '<strong>$1</strong>'), | |
value : term | |
}); | |
}); | |
response(output); | |
} | |
}); | |
}, | |
select: function(event, ui) { | |
this.value = ui.item.value; | |
jQuery(event.target).closest('form').submit(); | |
}, | |
delay: 0, | |
minLength: 3 | |
}); | |
} | |
var module = {}; | |
initialize(); | |
return module; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment