Fixed autocomplete bug
This commit is contained in:
parent
2f4411472a
commit
5bd2852894
|
@ -47,7 +47,7 @@ class ArtistController < ApplicationController
|
|||
return render :nothing => true if autocomplete.nil?
|
||||
suggestions = []
|
||||
autocomplete["response"]["docs"].each do |doc|
|
||||
suggestions << doc["artist"] unless suggestions.include?(doc["artist"])
|
||||
suggestions << doc["artist"] unless suggestions.include?(doc["artist"]) or doc["artist"].nil?
|
||||
end
|
||||
render :json => {
|
||||
:query => params[:query],
|
||||
|
|
|
@ -2,6 +2,7 @@ var Ajax = {
|
|||
loadArtistData: function(name) {
|
||||
$('#search-container input').attr('disabled', 'disabled').blur();
|
||||
$('#search-container img').show();
|
||||
console.log(1);
|
||||
name = name.replace(' ', '+');
|
||||
Ajax.setArchor('/artist/'+ name +'/');
|
||||
$.get('/artist/'+ name +'/', function(data){
|
||||
|
|
|
@ -271,15 +271,14 @@
|
|||
mOver = function(xi) { return function() { me.activate(xi); }; };
|
||||
mClick = function(xi) { return function() { me.select(xi); }; };
|
||||
this.container.hide().empty();
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
s = this.suggestions[i];
|
||||
if (typeof s == 'string') {
|
||||
div = $((me.selectedIndex === i ? '<div class="selected"' : '<div') + ' title="' + s + '">' + f(s, this.data[i], v) + '</div>');
|
||||
div.mouseover(mOver(i));
|
||||
div.click(mClick(i));
|
||||
this.container.append(div);
|
||||
}
|
||||
}
|
||||
this.enabled = true;
|
||||
this.container.show();
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue