create.rjs

来自「这是我在学习ruby的时候写的一个blog系统」· RJS 代码 · 共 8 行

RJS
8
字号
page.insert_html :bottom, :comments, :partial => "blogs/comment" ,:object => @comment
#这里是定义ajax插入页面的形式。第一个参数":bottom"定义插入的位置,comments是render所在的div的id,后面两个参数是定义render的参数
page["new_comment"].reset
#这里的new_comment是提交表单的id,这行代码的作用是清空表单项
page.replace_html :notice, flash[:notice]
#:notice是用来显示flash[:notice]的div的id
flash.discard
#如果没有这句,再完成ajax提交后再刷新页面,会在页面顶部显示flash[:notice]内容

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?