- 原文作者:FriendsOfSymfony
- 授权许可:创作共用协议
- 翻译人员:FireHare
- 校对人员:
- 适用版本:FOSCommentBundle 2.0.5
- 文章状态:草译阶段
Step 13: Hooking into the JS code
The FOSCommentBundle Js code fires events on the thread container object.These events are triggered, for example, when users cancel a comment or reply to a comment.
FOSCommentBundle功能包的Js代码触发线索容器对象中的事件。举个例子,当用户忽略或回复评论时,这些事件将被触发。
fos_comment_before_load_thread( identifier )
Triggered before getting the comments of a thread and placing them in the thread holder.
在得到评论线索之前被触发,并将它们放置在线索保持器中。
identifier: unique identifier url for the thread comments
标识符:线索评论的唯一标识
fos_comment_new_comment( data )
Triggered if the request about a new comment submission succeeds.
在请求提交新评论成功时被触发。
data: data sent to the server with the request.
数据:和请求一起发送到服务器的数据。
fos_comment_submitted_form( statusCode )
Triggered when the request about a new comment submission is completed.
当请求提交新评论完成时被触发。
statusCode: status of the server response
状态码:服务器回覆的状况
fos_comment_submitting_form( )
Triggered before posting the new comment form.
在发送新评论表单之前触发。
Preventing the default action will cancel the submission of the comment.
防止缺省Action取消评论提交。
fos_comment_show_form( data )
Triggered when the reply form is inserted into the DOM tree.
当回复表单被插入到 DOM树时被触发。
data: the reply form content
数据:回复表单内容
fos_comment_cancel_form( )
Triggered when the comment reply is closed.
当评论回复关闭时触发。
Preventing the default action will cancel closing the form.
防止缺省Action取消正在关闭的表单。
fos_comment_edit_comment( data )
Triggered if the request about editing a comment succeeds.
当请求编辑评论成功时触发。
data: data sent to the server with the request.
数据:和请求一起发送到服务器的数据。
fos_comment_vote_comment( data )
Triggered when the the request about voting a comment succeeds.
当请求对一个评论投票成功时触发。
- data: data sent to the server with the request.
- 数据:和请求一起发送到服务器的数据。
fos_comment_add_comment( commentHtml )
Triggered when the comment is inserted into the DOM tree.
当评论被插入DOM树时触发。
commentHtml: jQuery object to insert into the DOM tree.
commentHtml: 插入到DOM树中的jQuery对象
fos_comment_removing_comment( )
Triggered before a comment delete action.
在评论删除操作之前触发。
Preventing the default action will cancel the removal.
防止缺省操作取消删除。
fos_comment_show_edit_form( data )
Triggered when the edit form is inserted into the DOM tree.
当编辑表单被接入DOM树时触发。
data: the edit form content
数据:编辑表单内容
Example:(示例)
$(document) .on('fos_comment_show_form', '.fos_comment_comment_reply_show_form', function (event, data) { // do stuffs });
That is it!
返回到指南索引页。