I am using the LOAD command to invoke a custom comment module in a
view like this:
{{=LOAD('comments','comment',args=(r.id), ajax=True)}}{{pass}}

The LOAD statement is called for each row displayed on the view .
Note there are multiple rows.


The controller is very straight forward and looks like this:
---------------------------------------------------------------------------------------------------------------
def comment():
    print 'in comment controller with item_id = ', request.args(0)

    item_id=request.args(0)
    db.itemcomments.item_ref.default=item_id
    db.itemcomments.created_by.represent=lambda id:
db.auth_user[id].email
    form=SQLFORM(db.itemcomments, submit_button='Add')

    if form.accepts(request.vars, session):
        print request.vars
        sink=1
    elif form.errors:
        response.flash = 'Invalid data.'

 
comments=db(db.itemcomments.item_ref==item_id).select(orderby=db.itemcomments.created_on)
    return dict(form = form,comments=comments)
------------------------------------------------------------------------------------------


At 1st appearance everything looks fine.  The items are displayed
along with their corresponding comments.  The input text box is
displayed along with the add button.  The problem is that for any
given record the 1st time i try and add a new comment nothing
happens.  However, the 2nd and subsequent times I add comments for a
record it works.

Reply via email to