Am 15.01.10 06:48, schrieb Shane:
Hi,
I'm writing some custom code that wraps some JQuery javascript UI
components. Not writing widgets yet, just simple wrappers. Is there
a simple/clever way I can pass a boolean true from the TG side to the
JS in a template? I basically need an:
options.border=true
to appear in the template JS when all I can do is pass a string. The
only thing I can think of is to write a JS function to loop through
entire objects looking for values passed from TG (say a "TG_TRUE"
value) and when if finds one set this value to JS Boolean true. Is
there anything more clever than this? If no, is there a JS library/
function which does this that supports traversing through nested
objects?
I'd use ToscaWidgets. JSSource + inject should work. Out of my head:
@expose(...)
def controller(self, ..):
JSSource("""$(document).ready(
$("#%(element_id)s").do_something();
)""" % dict(element_id=the_id)).inject()
return {}
That should inject the JSSource as <script>-tag. If it's not working,
100% working is
class MyWidget(Widget):
javascript = [jquery_js]
template = ""
def update_params(self, d):
super(MyWidget, self).update_params(d)
self.add_callback("""<the same as above>""")
And then invoking display on an instance of MyWidget.
Diez
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.