Simply adding to current.response.files may not works if the request is
ajax (say your module is loaded).
In my modules I like to use a function the plugins in s-cubism.com use to
set files:
def _set_files(files):
if current.request.ajax:
current.response.js = (current.response.js or '') + """;(function
($) {
var srcs = $('script').map(function(){return $(this).attr('src');}),
hrefs = $('link').map(function(){return $(this).attr('href');});
$.each(%s, function() {
if ((this.slice(-3) == '.js') && ($.inArray(this.toString(), srcs) ==
-1)) {
var el = document.createElement('script'); el.type =
'text/javascript'; el.src = this;
document.body.appendChild(el);
} else if ((this.slice(-4) == '.css') && ($.inArray(this.toString(),
hrefs) == -1)) {
$('<link rel="stylesheet" type="text/css" href="' + this + '"
/>').prependTo('head');
if (/* for IE */
document.createStyleSheet){document.createStyleSheet(this);}
}});})(jQuery);""" % ('[%s]' % ','.join(["'%s'" % f.lower().split('?')[0]
for f in files]))
else:
current.response.files[:0] = [f for f in files if f not in
current.response.files]
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.