Your problem is that you have the {{...}} syntax in a js file:
shortcut.add("Ctrl+F12",function() {
window.open("{{=URL('default', 'index') }}", "_self");
});
but this is a static file, not a template and therefore it is the {{...}}
is never interpreted by web2py.
On Wednesday, 12 March 2014 00:32:42 UTC-5, 黄祥 wrote:
>
> hi,
>
> is it possible to have python in javascript extension file (*.js)?
> e.g.
> *views/layout.html*
> <script>
> shortcut.add("Ctrl+F12",function() {
> window.open("{{=URL('default', 'index') }}", "_self");
> });
> </script>
>
> then when i move it to javascript file
> *static\js\list_shortcut.js*
> shortcut.add("Ctrl+F12",function() {
> window.open("{{=URL('default', 'index') }}", "_self");
> });
>
> views/layout.html
> <script src="{{=URL('static','js/list_shortcut.js')}}"></script>
>
> it return an error
> *invalid request*
>
> what is the correct method to have python in javascript extension file?
>
> thanks and best regards,
> stifan
>
>
--
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.