> class TestWidget(JSUnit):
>     def __init(self, *args, **kw):
>         super(TestWidget, self).__init__(*args, **kw)
>         #self.javascript.append(all);
>         self.javascript.append(test_js);

The constructor is still odd. Whoever created that example didn't use tw 
idiomatic. And it in general seems to be a rather bad example, see below.

Use

class TestWidget(JUnit):
     javascript = [test_js]

instead, if you must use JUnit.


>     def update_params(self, d):
>         super(TestWidget, self).upadate_params(d)

Superflous, can go.


> 
> #templates/widgettest.html
> #...
>     ${tmpl_context.testwidget(value=value)}
> ===========================================
> ! UndefinedError: "value" not defined
> Where am I supposed to get this value from?


The value is supposed to be passed via returnvalue from the controller. 
I don't know what it is supposed to be for the JSUnit-widget, because 
the whole page doesn't care to mention this.

So, do yourself a favor, and ditch that whole thing. It is official 
docs, so it's sad that you stumbled over it. But it unfortunatly sucks.


Instead, try this:


class MyWidet(tw.api.Widget):


    javascript = [JSLink(__modname__, "myscript.js")] # make sure that 
the js is really under __modname__/myscript.js


    template = "<div>Hello world!</div>"
    engine_name = "genshi"


my_widget = MyWidget("test")


@expose("the.template")
def action(self, ...):
     c.my_widget = my_widget
     return dict


And in "the.template.html", do


${c.my_widget.display()}


This should work, render a jslink into the source, and the "hello 
world". From there on, try to expand, by e.g. using add_call inside 
"update_params" to render a piece of js that invokes code from myscript.js.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to