widgettest.html
===============
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:py="http://genshi.edgewall.org/";
      xmlns:xi="http://www.w3.org/2001/XInclude";>
  <xi:include href="master.html" />
<head>
  <meta content="text/html; charset=UTF-8" http-equiv="content-type"
py:replace="''"/>
  <title>Widget Test</title>
</head>
<body>
    <h1>Test A Dojo Chart Widget</h1>
    <br/>
    <!--
    <p py:content="form.display(submit_text='Yes')">Widget Form</p>
    UndefinedError: "tg" not defined
    -->
    <!--${tmpl_context.testwidget} here or inside div, no joy -->
    <div id="testUpdating" style="width: 300px; height: 300px;">
        This text will be replaced by a chart, I hope...
        ${tmpl_context.testwidget}
    </div>
</body>
</html>
=======
If I try this (in <head> or in <body>):

         <title>Widget Test</title>
         <script type="text/javascript">
             ${tmpl_context.testwidget.javascript}
         </script>
       </head>
I get:

Module genshi.template.eval:321 in lookup_attr
__traceback_hide__      True
cls     <class 'genshi.template.eval.StrictLookup'>
key     'javascript'
owner   ''
view
UndefinedError: '' has no member named "javascript"

The same error occurs if I go ${tmpl_context.testwidget.display()}
Why is Genshi looking for member "javascript" in '' (ie. the empty
string?) Obviously '' has no members but surely my testwidget should?

>BTW, in my example I used the modname/filenam-variant. Why did you
>change it? And did it work for you?
Yes, as with ${tmpl_context.testwidget} or ${pylons.c.testwidget},
they  seem to be interchangeable. Neither threw an error so I reverted
to the  simpler looking relative path, presuming that the default
location of  index.html is myproj/mypkg/public.
#javascript = [ JSLink(link=url('/js/chart.js')) ]
javascript = [ JSLink(modname=__name__, filename='public/js/
chart.js') ]

>Again this seems to be some exercise in genetic programming.
Mine is indeed a genetic algorithms project.  How you've twigged to
this  already, I'm not quite sure :-}

>self.add_jall("""$(document).ready(function() {
>     $("#%s").do_something();
>
>})""" % d.id)
As one might guess from my moniker, I'm more comfortable with the
database side of things than the front end. In my case however the
Dojo  chart.js script links methinks to <div id="testUpdating" and
the  do_something() is a function in chart.js but what's $(document)?

>And where does the "javascript" come from?
I thought this was a class attribute of tw.api.widget
"javascript
    A list of tw.api.JSLink or tw.api.JSSource instances that the
widget  should register for injection in the page whenever it is
displayed"

>Both the widget and the controller share the same template?
Ah, ha! How else is it supposed to work? I thought using the same
name,  ie. "pkg.templates.widgettest", was a necessary link between
two  otherwise disparate pieces of code. There's no HTML associated
with my  widget per se. The Dojo is all just functions.  So do I need
a dummy  form to set an action on where action="do_something()"?

> - unless you have a js-named controller on your root, and a
> chart_js-action on that
Or maybe, this is what I need to do.  What's a js-named controller?
What's a chart_js-action?
--~--~---------~--~----~------------~-------~--~----~
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