Skip to content

Instantly share code, notes, and snippets.

@svenwelte
Created September 11, 2013 15:09
Show Gist options
  • Save svenwelte/e6cc614010d38af1289e to your computer and use it in GitHub Desktop.
Save svenwelte/e6cc614010d38af1289e to your computer and use it in GitHub Desktop.
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