I am currently upgrading a Rails application. While I did manage to translate simpler JQuery calls, I got stuck with the more complex JQuery autocomplete.
Javascript
$(document).ready(function() {
var data_category = <%= @autocomplete_categories %>;
$("#entry_category").autocomplete({
source: function(req, responseFn) {
var re = $.ui.autocomplete.escapeRegex(req.term);
var matcher = new RegExp( "^" + re, "i" );
var a = $.grep( data_category, function(item,index) {
return matcher.test(item);
});
responseFn( a );
},
minLength: 0,
delay: 0,
autoFocus: true
});
Coffescript:
$ ->
data_category = <%= @autocomplete_category %>;
$("#entry_category").autocomplete({
I don’t manage to translate the two functions, please advise on the correct syntax!
1 Answer