Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Rails 4表单远程更新div问题_Ruby_Forms_Tags_Ruby On Rails 4 - Fatal编程技术网

Ruby Rails 4表单远程更新div问题

Ruby Rails 4表单远程更新div问题,ruby,forms,tags,ruby-on-rails-4,Ruby,Forms,Tags,Ruby On Rails 4,在使用Rails 4提交表单后,我在更新div时遇到了一些问题。以下是我的代码的相关部分: 视图: _details.html.haml = form_tag(url_for(save_answer_path(format: :js)), remote: true) do (some html code ....) = submit_tag t('app.bouton.send'), id: 'sendButton' %div#divlogs = render partial: 'log

在使用Rails 4提交表单后,我在更新div时遇到了一些问题。以下是我的代码的相关部分:

视图:

_details.html.haml

= form_tag(url_for(save_answer_path(format: :js)), remote: true) do
 (some html code ....)
 = submit_tag t('app.bouton.send'), id: 'sendButton'

%div#divlogs
 = render partial: 'logs'
控制器:

JS:

save_answer.js.erb

$('#divlogs').html("<%= escape_javascript(render partial: 'logs') %>");
我在屏幕上看到的是:

$('#divlogs').html("<p>This should appear on the div </p>");
$('#divlogs').html(应该出现在div上);

有人知道发生了什么吗?

解决方案:

正如@VladKhomich在上面的评论中所说,我缺少JS文件rails.JS


您可以从这里下载它:

您是否尝试过
表单标签(保存答案路径,远程:true)
。这应该足够了。您还应该检查rails.js是否被使用(检查页面源代码)。谢谢您的回答。是的,我尝试了很多东西,但我得到了一个错误:ActionController::UnknownFormat(ActionController::UnknownFormat):@VladKhomich没有rails.js的踪迹。我会做必要的。@VladKhomich非常感谢,就是这样!你能写个答案让我验证一下吗?
http://domaine/controller/save_answer.js
$('#divlogs').html("<p>This should appear on the div </p>");