1
0
Fork 0

Fixed autocomplete bug

This commit is contained in:
magnolia-fan 2011-06-16 04:31:37 +04:00
parent 2f4411472a
commit 5bd2852894
3 changed files with 353 additions and 353 deletions

View File

@ -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],

View File

@ -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){

View File

@ -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();
},