The problem is that response.files are inserted in the <head> of the layout, but components are loaded via ajax after the main page has been loaded, so your code will have no effect. You could call response.include_files() after appending the files -- that will insert the relevant code right there in your .load view. That should work for the JS files, which can be included anywhere, but the css file should be linked in the page <head> instead. To do that, I think you can use jQuery to append the needed <link> element to the document <head>.
Anthony On Tuesday, June 25, 2013 3:24:35 PM UTC-4, RHC wrote: > > I am trying to create a component plugin. I would like to add in some > javascript and css files from the plugin with as little editing as possible. > > I have a view.load file as part of the plugin and I tried to add something > like this to the top of this view file: > > {{ > > response.files.append(URL('static','plugin_spectrum/spectrum/spectrum.css')) > response.files.append(URL('static','plugin_spectrum/spectrum/spectrum.js')) > response.files.append(URL('static','plugin_spectrum/plugin.js')) > }} > > However, these files are not being loaded. I would like to make it as easy > to add the component into a web page as possible using a {{=LOAD(....)}} > command in the relevant views. It seems a bit cumbersome to have to add > these into the relevant layout.html as well as in the specific views. > > Is what I am trying to do possible? If not, is there another way to load > up the associated files along with the plugin automatically wherever the > component is loaded into the view? > > Thanks, > > Richard. > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.