Skip to content

Instantly share code, notes, and snippets.

@svenwelte svenwelte/example Secret
Created Sep 11, 2013

Embed
What would you like to do?
Example usage of _render_menu
_renderMenu: (ul, items) ->
self = this
ul.addClass @options.popupClass if @options.popupClass
$.each items, (index, item) ->
switch item.renderer
when "category"
$("<li class='ui-autocomplete-item ui-autocomplete-group category-" + item.category + "'>" + item.label + "</li>").appendTo ul
when "message"
$("<li class='ui-autocomplete-item ui-autocomplete-message'>" + item.label + "</li>").appendTo ul
when "multiline"
template = _.template("<li><a><%= label %><br/> <small><%= additionalInfo %></small></a></li>")
$(template(item).toString()).data("ui-autocomplete-item", item).appendTo ul
when "extra-classes"
template = _.template("<li class='<%= classes %>'><a><%= label %></a></li>")
$(template(item).toString()).data("ui-autocomplete-item", item).appendTo ul
when "action"
template = _.template("<li class='special-action <%= classes %>'><a><%= actionLabel %></a></li>")
$(template(item).toString()).data("ui-autocomplete-item", item).appendTo ul
else
self._renderItemData ul, item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.