Maybe try having the post comment action return some JS via response.js that
calls the web2py_component JS function to update the list component:
def post_comment():
# do some stuff
response.js='web2py_component(action="%s",target="%s")' %
(URL('list_comments.load'), 'comment_list')
return dict(...)
def list_comments():
# code to list comments
In view:
{{=LOAD('post_comment.load', ajax=True)}}
{{=LOAD('list_comments.load', target='comment_list', ajax=True)}}
See
http://web2py.com/book/default/chapter/13#Client-Server-Component-Communications
.
Anthony
On Friday, June 10, 2011 8:44:26 PM UTC-4, 黄祥 wrote:
> hi,
>
> is ajax can work in components? i mean let say that i separated the
> comment into 2 components, 1 for list of view comments and the other
> is form to post the comment. i have a problem when i post the comment
> using the form, the data that have been posted is not directly change
> on list of comments (the other components), i must refresh my browser
> many times so that the list comments can show the latest posted
> comment. is there any clue or solution to implement ajax that works in
> other components?
>
> any hints, suggestion is greatly appreciate.
> thank you very much.