var Search = { showSpinner: function() { $('#search-container input').attr('disabled', 'disabled').blur(); $('#search-container img').show(); Search.hideSuggestions(); }, hideSpinner: function() { $('#search-container input').removeAttr('disabled'); $('#search_field').focus(); $('#search-container img').hide(); }, showSuggestions: function(values) { for (var i = 0; i < values.length; i++) { $('.suggestions ul').append('\ <li>\ <a class="data artist">'+ values[i].name +'</a>\ '+ (values[i].desc ? '<span>('+ values[i].desc +')</span>' : '') +'\ </li>\ '); } $('.suggestions').css('margin-left', $('#search_field').offset().left +'px').show(); }, hideSuggestions: function() { $('.suggestions ul li').remove(); $('.suggestions').hide(); }, showArtistPics: function(pics) { $('.artist_loading, .artist_pics').show(); $('.artist_pics').html(''); for (var i = 0; i < pics.length; i++) { $('.artist_pics').append('\ <div class="pic">\ <img src="'+ pics[i] +'" alt=""/>\ </div>\ '); } } } $(function(){ $('.search').live('click', function(){ Ajax.loadSearchPage(); return false; }); $('#search_form').live('submit', function(){ $('.autocomplete-container').remove(); Ajax.loadArtistData($('#search_field').val()); return false; }); $('.suggestions a').live('click', function(){ $('#search_field').val($(this).text()); return false; }); });