Skip to content

Instantly share code, notes, and snippets.

@MarkBorcherding
Forked from doxavore/gist:736619
Created December 10, 2010 19:08
Show Gist options
  • Save MarkBorcherding/736634 to your computer and use it in GitHub Desktop.
Save MarkBorcherding/736634 to your computer and use it in GitHub Desktop.
// jQuery barfs because $(empty).data("autocomplete") => undefined
$(".course-autocomplete").autocomplete({
source: "/courses/autocomplete.json"
}).data("autocomplete")._renderItem = function(ul, item) {
return $("<li>")
.data("item.autocomplete", item)
.append("<a>" + item.name + "</a>")
.appendTo(ul);
};
// jQuery likes but my fingers don't
$(".course-autocomplete").autocomplete({
source: "/courses/autocomplete.json"
});
if ($(".course-autocomplete").length) {
$(".course-autocomplete").data("autocomplete")._renderItem = function(ul, item) {
return $("<li>")
.data("item.autocomplete", item)
.append("<a>" + item.name + "</a>")
.appendTo(ul);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment