Skip to content

Instantly share code, notes, and snippets.

@ilake
Created May 18, 2013 01:57
Show Gist options
  • Save ilake/5602948 to your computer and use it in GitHub Desktop.
Save ilake/5602948 to your computer and use it in GitHub Desktop.
jQuery ->
$('#student_query_string').autocomplete
source: "/admin/autocomplete"
select: (event, ui)->
location.href = '/admin/students/' + ui.item.uid
open: (event, ui)->
$(".autocomplete_avatar").each (index, elem)->
$(elem).attr("src", $(elem).data('src'))
.data( "ui-autocomplete" )._renderItem = ( ul, item )->
$( "<li>" ).append( "<a><img class='autocomplete_avatar' data-src='" + item.avatar + "' src='<%= asset_path('fallback/thumb_default_avatar.png') %>'><span>" + item.name + "</span></a>" ).appendTo( ul )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment