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