[英]Update Div without reload page using Ajax in Rails
In my View af_form.html.erb 在我的视图af_form.html.erb中
I have a button for trrigering ajax call 我有一个trrigering ajax调用的按钮
<%= button_to('update ', {:action => 'update', :thingyid => 314}, :method => :get, :remote => true , :'data-update-target' => 'af_stat' ) %>
<div id="af_stat" >
<h3>Tiltle :
<%= @kk %>
</h3>
somebody says I should have a file called _af_form.html.erb what should the _af_form.html.erb should be? 有人说我应该有一个名为_af_form.html.erb的文件_af_form.html.erb应该是什么?
In my controller welcome , there is an method 在我的控制器欢迎中,有一种方法
def update
@kk = @kk +1
render :partial => 'af_form', :content_type => 'text/html'
end
I heard someone said..."just same as af_form.js.erb" ? 我听说有人说......“就像af_form.js.erb一样”? isn't it stupid?
不是很蠢吗? copy two identical files.and disobey DRY rule.
复制两个相同的文件。并且不遵守DRY规则。
and it doesn't work . 它不起作用。 what's wrong.
怎么了。 anyone can help me.
任何人都可以帮助我。 thanks you very much.
非常感谢你。
i just want to change the view af_form.html.erb not _af_form.html.erb , why should i need _af_form.html.erb 我只想更改视图af_form.html.erb而不是_af_form.html.erb,为什么我需要_af_form.html.erb
在update.js.erb
尝试这个
$('#af_stat h3').text('Title: <%= escape_javascript @kk %>');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.