Spoke to soon the div does not update.

What I am after is the div song_list refreshing in real time. I appreciate
any help offered

*cheers

*controllers*

def index():
    return dict()

def page_with_form():
    return dict()

def ajax_example():
    rows = db(db.music2.id>0).select()
    return dict(rows=rows)

def myform():
    form = SQLFORM(db.music2)
    if form.accepts(request.vars):
       response.flash='Thanks for filling the form'
       #"%s",[],"song_list" is a reference to a div that gets called and
updated
       return XML('ajax("%s",[],"song_list");' % URL('default',
'ajax_example.load'))
    elif form.errors:
        response.flash='Fill the form correctly'
    else:
        response.flash='Please, fill the form'

    return dict(form=form)

*index view
*
{{extend "template.html"}}

<div id="content">
 {{=LOAD('default', 'ajax_example.load', ajax=True)}}
</div>
*
page_with_form_view
*
{{extend "template.html"}}
<div id="content">

 {{=LOAD('default', 'myform.load', ajax=True)}}

</div>
*
ajax_example.load
*
<div id="song_list">
{{for song in rows:}}

{{filename, file = db.music2.song.retrieve(song.song)}}
<a href="{{=URL('download', args=song.song)}}">  {{=filename}}</a>
<br /><br />
{{pass}}
</div>

the last load file just contains a {{=form}}

Reply via email to