Can you pack and attach a minimal app the reproduces the problem?
On Monday, May 14, 2012 2:08:47 AM UTC-4, Larry Weinberg wrote:
>
> I'm not sure if this is web2py question or javascript related issue.
>
> In an HTML view I am trying to call a subview with a form in it that has a
> jquery
> autocomplete attached to a text field in the form.
> I attach the autocomplete like this in the form view's document ready
> function:
>
> $(document).ready(function(){
> $('#autome').autocomplete({
> source: function(request, response) {
> $.ajax({ url: "/myapp/mycontroller/myautocomplete.json",
> data: request,
> dataType: "json",
> type: "POST",
> success: function(data){ response(data.source)}
> })}});
> });
>
> It works fine the first time the form is loaded as a subview via LOAD.
> Once the form is processed through self-submission the autocomplete no
> longer works even though
> the ready function is being called again.
>
> I'm loading the view like this:
>
> <div style="position:absolute;top: -8px;width:956px;min-width:956px;">
> {{=LOAD('default/ajaxsearch',ajax=True)}}
> </div>
>
>
> If I run the form by itself (not in a LOAD) the autocomplete works before
> and after form submission as expected.
>
> Here is the function for the inner form:
>
> def innerform():
> items=[]
>
> form=FORM(DIV(TABLE(TR(INPUT(_name='q',_id="autome",requires=IS_NOT_EMPTY(),_keepvalues=False),
> INPUT(_type='submit',_value='Search')
> ))),_method='GET')
> if form.accepts(request.vars,session=None):
> items = doMyStuff()
> return dict(form=form,items=items)
>
> Can anyone tell me why?
>
> Thanks
>
>
>