The problem with this approach is that you can longer embed widgets in
regular views via {{=plugin_wiki.widget(name,**attr)}} because the
response.files list would be updated after the response.files are
included.

Massimo

On Aug 9, 4:43 pm, Chris S <[email protected]> wrote:
> When using plugin_wiki (or just the LOAD command in general) is it
> possible to somehow include response.files to include custom css and
> js files?
>
> It would be nice if I could only load .js files which are widget
> specific if that widget is in use.  I really don't want to have to
> load every .js file for every possible widget in a model (which
> works).  Here's what I've tried simplified a bit.
>
> In models/widgets.py
> class PluginWikiWidgets:
>     @staticmethod
>     def mywidget(table='None',record_id=None):
>     response.files.append(URL(request.application,'static/
> widgets','widget.js'))
>     // widget code
>    return('widget.html',d)
>
> In plugin_wiki body:
> ``
> name: mywidget
> table: None
> ``:widget
>
> There is of course a 'widget.html' which renders the HTML portion of
> the widget.
> However, doing this none of my .js files load for the widget.  Moving
> the response.files calls
> before the class definition in the model works, but means that it's
> loaded on every call to the application.
>
> I've tried doing the response.files.append calls in the .html file at
> the beginning but it's the same thing.
> My suspicion is that the header is already loaded before plugin_wiki
> renders the body and hence
> the appended files are never loaded.  Is there a way around this?  It
> would be much better if I could write
> several widgets using different jQuery plugins and know that only the
> widgets in use will get loaded when needed.

Reply via email to