summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalph Bean <ralph.bean@gmail.com>2011-04-13 21:06:13 -0400
committerRalph Bean <ralph.bean@gmail.com>2011-04-13 21:06:13 -0400
commit6e50e82fb40c77b059c4ff2eae936cb779303a63 (patch)
tree04ba06b852fb50bdff4ec9d4a6f335f8c980d83f
parent185d81c0eca65f5bbaf269a3a014b5e90943c700 (diff)
downloadleafymiracle-6e50e82fb40c77b059c4ff2eae936cb779303a63.tar.gz
leafymiracle-6e50e82fb40c77b059c4ff2eae936cb779303a63.tar.xz
leafymiracle-6e50e82fb40c77b059c4ff2eae936cb779303a63.zip
Javascript hack to make HTML in JSON work.
-rw-r--r--leafymiracle/static/js/searchbar_html_support.js14
-rw-r--r--leafymiracle/widgets.py10
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 = []