I found out that if the java scrip files (.js files) are loaded in the
initial load of the page the embedded javascript of the ajax loaded
pages is executed
e.g.
default.py
def index():
response.files.append(URL(request.application,'static/jquery-
autocomplete','jquery.autocomplete.pack.js'))
response.files.append(URL(request.application,'static/jquery-
autocomplete','jquery.autocomplete.css'))
response.files.append(URL(request.application,'static/jquery-
autocomplete','jquery.autocomplete.pack.js'))
response.files.append(URL(request.application,'static/jquery-
autocomplete/lib','jquery.bgiframe.min.js'))
response.files.append(URL(request.application,'static/jquery-
autocomplete/lib','jquery.dimensions.js'))
return dict()
def test():
form = form_factory(Field('myfield'))
script = SCRIPT('''$(document).ready(function(){
$("#no_table_myfield").autocomplete(["a","b"]);
});''')
return TAG[''](form, script)
default/index.html
LOAD('default', 'test', ajax=True)
this works
in additioin to that I read that the ajax function can load
javascrips ... this could mean that something along the lines of
script = SCRIPT('''$(document).ready(function(){
jQuery.ajax(url: "%s")
$("#no_table_myfield").autocomplete(["a","b"]);
});'''%URL(request.application,'static/jquery-
autocomplete','jquery.autocomplete.pack.js'))
could fix some problems, I did not try it out yet since I spend too
much time already figuring out the first issue
On Apr 15, 2:34 pm, selecta <[email protected]> wrote:
> I guess one of these linked libs will help to solve the
> problemhttp://ajaxpatterns.org/On-Demand_Javascript
> I am hitting this border more often now since I develop everything
> modular now and it is getting quite annoying
>
> On Apr 8, 3:02 pm, selecta <[email protected]> wrote:
>
>
>
> > currently i'm quite buisy but i will send you a test app soon
> > my data
> > on Ubuntu 9.10
> > opera 10.10, google-chrome-beta 5.0.342.9-r43360, firefox 3.5.8
> > web2py 1.76.3 and whatever jquery version comes with it
>
> > On Apr 7, 12:24 pm, DenesL <[email protected]> wrote:
>
> > > Hi selecta, can you send me a test app?.
> > > I have been testing and documenting ajax in web2py 1.76.3 in my spare
> > > time.
>
> > > Which jQuery, browser and web2py versions are you using?.
>
> > > On Apr 5, 5:05 pm, selecta <[email protected]> wrote:
>
> > > > I tried to use Recaptcha in a LOAD div but I does not work
>
> > > > The problem is that the page stats reloading when it gets to the div
> > > > loaded with LOAD where the recaptcha javascripts are in and gets stuck
> > > > on reloading it
>
> > > > controller:
> > > > ...
> > > > form = SQLFORM.factory(Field('tag_name'))
> > > > captcha = None
> > > > if not auth.user:
> > > > captcha = Recaptcha(request,'xxx','xxx')
> > > > form[0].append(captcha)
> > > > if request.vars.tag_name:
> > > > ....
> > > > if form.accepts(request.vars, session):
> > > > ...
> > > > return dict(form=form, captcha = captcha)
>
> > > > view tag.html:
> > > > {{=form.custom.begin}}
> > > > ...
> > > > {{=captcha}}
> > > > {{=form.custom.end}}
> > > > {{pass}}
>
> > > > view default.html:
> > > > LOAD('default','tag',args=(table_name,record_id),ajax=True) <- does
> > > > not work
>
> > > > but with
> > > > LOAD('default','tag',args=(table_name,record_id))
> > > > at least the page loads
--
Subscription settings: http://groups.google.com/group/web2py/subscribe?hl=en