hi Stifan

The LOad components is really helpful. However i seem to be loading the 
same form in all my sections. Can you perhaps help me out if you have tried 
this before. I can see that the database does not even assign the comments 
to a certain form.
How can i ensure each comment is associated with a form. i thought the DIV 
or target in the index.html should tell it which form to load but it seems 
i am making a mistake somewhere. Currently this code loads the same form 
everywhere.
This is my code:

*comments.py*

@auth.requires_login()
def post():
    return dict(form=SQLFORM(db.comment_post).process(),
                comments=db(db.comment_post).select())

*post.html*

{{extend 'layout.html'}}
{{for post in comments:}}
<div class="post">
  On {{=post.created_on}} {{=post.created_by.first_name}}
  says <span class="post_body">{{=post.body}}</span>
</div>
{{pass}}
{{=form}}


*post.load*

{{for post in comments:}}
<div class="post">
  On {{=post.created_on}} {{=post.created_by.first_name}}
  says <blockquote class="post_body">{{=post.body}}</blockquote>
</div>
{{pass}}
{{=form}}


*db_comments.py*

db.define_table('comment_post',
   Field('body','text'),
   auth.signature)


*default.py*

def index():
    form = SQLFORM(db.comment_post)
    if form.process().accepted:
        if request.vars.reload_div:
            response.js =  "jQuery('#%s').get(0).reload()" % 
request.vars.reload_div
    return dict()


*index.html*

{{extend 'layout.html'}}

{{=LOAD('comments','post.load',ajax=True,vars={'reload_div':'map'}, 
target='map')}}

A defining characteristic of wiki technology is the ease with which pages 
can be created and updated. Generally, 
there is no review before modifications are accepted. Many wikis are open 
to alteration by the general public without 
requiring registration of user accounts. 

{{=LOAD('comments','post.load',ajax=True,vars={'reload_div':'maths'}, 
target='maths')}}

Many edits can be made in real-time and appear almost instantly online. 
This 
can facilitate abuse of the system. Private wiki servers require user 
authentication to edit pages, and sometimes even 
to read them.






On Monday, 23 February 2015 17:24:24 UTC+2, niki wrote:
>
> This is really helpful. i can easily post for a single section. However 
> for multiple sections, i am still trying to figure it out. Thanks so much.
>
> On Monday, 23 February 2015 15:24:19 UTC+2, 黄祥 wrote:
>>
>> perhaps you can use load component
>> ref:
>>
>> http://www.web2py.com/books/default/chapter/29/12/components-and-plugins#LOAD
>>
>> best regards,
>> stifan
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to