使用Rails 4.2.4
我在rails中生成了一个脚手架来测试filepicker。一切似乎都运行良好,除非我在具有文件选择器按钮的页面上点击刷新,页面上显示3个按钮而不是原始1.这在Safari和Chrome上都会发生。有谁能告诉我如何解决这个问题?
首次加载页面时,只需一个按钮:
刷新时:
application.html.erb source:
<!DOCTYPE html>
<html>
<head>
<title>FilepickerTest</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>
<%= filepicker_js_include_tag %>
<%= yield %>
</body>
</html>
_form.html.erb source:
...
<div class="field">
<%= f.label :filepicker_url %><br>
<%= f.filepicker_field :filepicker_url, :button_text => "Select Image", :button_class => "btn btn-default", :onchange => 'onImageUpload(event)' %>
</div>
<div class="actions">
<%= f.submit 'Upload Image' %>
</div>
...
答案 0 :(得分:0)
问题与turbolinks有关,并通过删除application.html.erb文件中的javascript调用来修复。