Hi everyone, I'm new here , sorry for the english
 already made what facebook do with comments, everything works fine,
but i'm having an issue that worried me. Sometimes the submit fails
with secondary comments, it doesn't send anything to the controller,
but when you try again it works fine, i'm using the LOAD()
function....perhaps is a validation issue or a framework problem with
ajax LOAD() function...not sure...here is the code:

db.define_table('comment',
   Field('body',label='Comment'))


db.define_table('comment2',
   Field('body',label='Comment'),
   Field('idcomentario',db.comment))


db.comment.body.requires=IS_NOT_EMPTY()
db.comment2.body.requires=IS_NOT_EMPTY()
db.comment2.idcomentario.writable = db.comment2.idcomentario.readable
= False

/////////////////////////////////////////////////////////////////////////////////////


def index():

    form = SQLFORM(db.comment,fields=['body'])
    if form.accepts(request.vars,session):
        response.flash='OK'

    lista = db(db.comment.id>0).select()

    return dict(form=form,lista=lista)

def post():

    comentario=db(db.comment.id==request.args[0]).select()[0]
    form = SQLFORM(db.comment2,fields=['body'])
    form.vars.idcomentario=comentario.id

    if form.accepts(request.vars,session):
         response.flash='OK'

    comments=db(db.comment2.idcomentario==comentario.id).select()

    return dict(form=form,comments=comments)

//////////////////////////////////////////////////////////////////////////////
index.html
{{extend 'layout.html'}}
<h2>Postea un comentario:</h2>

{{=form}}

{{if len(lista):}}
{{for elem in lista:}}
     <h3>{{=elem.body}}</h3>
     {{=LOAD('default','post.load',args=[elem.id],ajax=True)}}
 {{pass}}
{{else:}}

{{pass}}


////////////////////////////////////////////////////////////////////////////////////////////////////////
post.html

{{extend 'layout.html'}}

{{if len(comments):}}
{{for comment in comments:}}
   <h5>{{=comment.body}}</h5>
{{pass}}
{{else:}}
{{pass}}

{{=form}}

///////////////////////////////////////////////////
post.load

{{if len(comments):}}
{{for comment in comments:}}
   <h5>{{=comment.body}}</h5>
{{pass}}
{{else:}}
{{pass}}

{{=form}}




Reply via email to