diff options
-rw-r--r-- | leafymiracle/static/js/searchbar_html_support.js | 14 | ||||
-rw-r--r-- | leafymiracle/widgets.py | 10 |
2 files changed, 24 insertions, 0 deletions
diff --git a/leafymiracle/static/js/searchbar_html_support.js b/leafymiracle/static/js/searchbar_html_support.js new file mode 100644 index 0000000..4d07901 --- /dev/null +++ b/leafymiracle/static/js/searchbar_html_support.js @@ -0,0 +1,14 @@ +// Add the hook in for catcomplete. +// We add it here instead of a tw2.jquery_ui template because it must +// be executed before *any* other plugins reference jquery ui proper + +$(document).ready(function() { + $.widget( "custom.catcomplete", $.ui.autocomplete, { + _renderItem: function( ul, item) { + return $( "<li></li>" ) + .data( "item.autocomplete", item ) + .append( $( "<a></a>" ).html( item.label ) ) + .appendTo( ul ); + } + }); +}); diff --git a/leafymiracle/widgets.py b/leafymiracle/widgets.py index 91b06d5..bf96e3a 100644 --- a/leafymiracle/widgets.py +++ b/leafymiracle/widgets.py @@ -18,6 +18,7 @@ from tw2.jqplugins.ui import DialogWidget from tw2.jqplugins.ui import CategoryAutocompleteWidget from tw2.core.resources import JSSymbol +from tw2.core.resources import JSLink import docutils.examples @@ -88,7 +89,16 @@ class LeafyDialog(DialogWidget): } value = leafy_readme() +searchbar_html_support_js = JSLink( + link='/static/js/searchbar_html_support.js') + class LeafySearchbar(CategoryAutocompleteWidget): + def prepare(self): + # Add this javascript hack into the client that makes jquery-ui + # render html embedding in JSON. :D:D:D:D:D + self.resources.append(searchbar_html_support_js) + super(LeafySearchbar, self).prepare() + id = 'leafy_searchbar' value = "Leafy Searchbar" tags = [] |