To link the JS file to your widget:
* if you don't use a specific template for your widget, add the
attribute :
javascript=[JSLink("myapp", "javascript/myjsfile.js")]
to your widget declaration .
* If you use a specific template, you can include the link to your js
file in the head of this template like:
<script type="text/javascript" src="/static/javascript/myjsfile.js"></
script>

Then, do your work in the javascript file; you can use mochikit for
instance to connect to the onchange event of your singleselectfield,
call XMLHTTPRequest etc.
If you use mochikit (or anotherr library), don't forget to include it
in the head of your template
<script type="text/javascript" src="/tg_static/js/MochiKit.js"></
script>
or via the application config file if you want to include mochikit in
all your pages.

Hope this helps


On Mar 19, 12:35 pm, Michael Pearce <[email protected]> wrote:
> Can someone please advise how to initiate a javascript function from a TG
> Widget. I have a WidgetList containing a number of widgets, including a
> SingleSelectField which is rendered as a standard html select control. In
> normal html code I would use the onchange function to initiate a javascript
> function. But how do you do this with a widget? How do I access the onchange
> function within the SingleSelectField object? Is there a parameter that I
> can use to initiate the onchange function? There's not much documentation on
> this. Any assistance would be greatly appreciated.
>
> Rgds,
> Michael
--~--~---------~--~----~------------~-------~--~----~
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