Hi.

1.
If you want to open a file you have to give the file with path on the file 
system 
and not through url.
I do like this:

import os
filename = os.path.join(request.folder, 'modules', 'appsettings.py')

request.folder contains the path to the current application

2.
I think it's bad idea to rewrite web2py_ajax.html dynamically. It's not thread 
safe. So if multiple people are trying to get the controller, you can't 
predict what will happen.
I your case I would do like this:

<div id="user1">user1<br><span id="hide_user1" 
onclick="$("div#user1").hide()">hide</span></div>

Also pay attention to the ids of the elements. Like in Highlander... there can 
be only one, with one name. :)
You can replace the jQuery with $ sign, to be shorter.

If you need some code to execute on document load, you can add a 
document.ready jquery function code in your view. They are "added" together 
before executing. So you can define as many as you need.

regards
mmlado

On Sunday 30 August 2009 10:37:59 tititi wrote:
> I want to open and append a javascript file (placed in Static folder)
> from default.py file but not seem to get past the error:
>
> filename = URL(r=request,c="static",f="jquery_dynamic.js")
>
>     try:
>         logfile = open(filename , 'w')
>
>         for each in restaurantsFeatures:
>             logfile.append('jQuery("span#thumbme%d"%each')
>         logfile.close()
>         msg = "The file exists"
>     except IOError:
>         msg = 'error
>
> Why am I getting this error? Does this have anything to do with the
> chmod issues?
>
> IOError: [Errno 2] No such file or directory: '/Que_Hay_de_Comer/
> static/jquery_dynamic.js'
>
> 2nd part of the question: I want to know if there is a better approach
> in dynamically writing jQuery lines in web2py_ajax.html. Let's say,
> I'm extracting a list of users wrapped in DIVs and with jQuery to
> enable the user to hide or show the DIV. For example:
>
> index.html
>
> <div id="user1">user1<br><span id="user1">hide</span></div>
>
> Now inside the document.ready jQuery function I would put:
>
> web2py_ajax.html
>
> jQuery("span#user1").click(function() {
>     jQuery("div#user1").hide()
> });
>
> So if I add more lines on list of index.html, I also to add lines for
> jQuery to manipulate these same lines. At this moment, I'm <<include>>
> a file to place these lines into the web2py_ajax.html. Is there a
> better way to do this? Thanks.
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to