Jquery脚本不能很好地使用涡轮链接
jquery script not working well with turbolinks
我有一个索引在我的应用程序,其视图包括一些过滤选项。一旦这些被选中,结果将被过滤。这一切都很好,只是在第一次进入索引时,所有这些脚本都不起作用,并且需要重新加载页面才能正常工作。我试过使用jquery.turbolinks
宝石,没有做任何事情。有什么建议吗?
index.html.erb:
<% content_for :on_document_ready_js_script do %> #this being yielded on layout
$("#er_filters").change(function() {
var url = "/examinee_registrations.js"; // grab the URL from the form action value.
$.get(url, $("form").serialize());
});
<% end %>
<div id="title">
<h1>
<%=t("examinee_registration.title")%>
<% if @location_id %>
<span id="<%=@location_id%>"> <%=t("for") + " #{Location.find(@location_id).name}" %> </span>
<% end %>
</h1>
</div>
<br>
<%= form_tag examinee_registrations_url(format: "xls"), method: :get do %>
<div id="er_filters">
<br>
<%= hidden_field_tag 'location_id', @location_id %>
<%= label_tag 'from_date', t("from_date")+':' %>
<%= date_field_tag "from_date" %>
<br>
<%= label_tag 'to_date', t("to_date")+':' %>
<%= date_field_tag "to_date" %>
<br>
<%= label_tag 'hide_open', t("examinee_registration.hide_open")+':' %>
<%= check_box_tag "hide_open", true, false %>
<br>
<%= label_tag 'hide_closed', t("examinee_registration.hide_closed")+':' %>
<%= check_box_tag "hide_closed", true, false %>
</div>
<%= submit_tag t('export_to_excel') %>
<% end %>
<br>
<%= link_to create_title('examinee_registration.single')+"ה", new_examinee_path %>
<hr>
<div id='er_div' >
<%= render 'examinee_registrations' %>
</div>
application.js:
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
index.js.erb:
$("#er_div").html("<%= escape_javascript(render 'examinee_registrations') %>");
为什么要使用涡轮链接?除非你有一个非常好的,经过深思熟虑的理由,只有涡轮链接才是答案,否则我建议你放弃它。
相关文章:
- 我发现了一些只在移动设备上可见的垃圾邮件链接,我可以'找不到包含此垃圾邮件链接的脚本的位置
- 什么's使用链接和脚本标记引用JavaScript源之间的区别
- Javascript:在新页面中打开链接并运行脚本
- 如何通过分配单个变量来减少此脚本中的链接数
- jQuery Pan & Zoom 或 Magnify 脚本,具有热点或图像映射链接的能力
- 是否有脚本/代码可以一次将链接属性添加到多个链接
- 阅读第'页;s从chrome扩展中链接的脚本
- 脚本链接格式以实现跨浏览器兼容性
- 用于浏览器检测和url链接的脚本
- Javascript一页滚动脚本滚动到每个点击的链接一个接一个
- 多个脚本导致链接问题?Javascript、CSS、HTML、Jquery
- 在grumjs-minify/uglify之后更改html中的链接或脚本文件名
- 随机引用超链接脚本
- xdomain.js跨域链接脚本的jQuery indexOf错误
- 没有链接脚本或样式表的HTML
- 独立的web应用链接脚本-阻止它附加具有特定类的链接
- 有没有办法知道链接/脚本是否仍然挂起或失败
- facebook共享链接脚本
- 让Javascript在新窗口中省略外部链接脚本的锚标记
- 试图添加更多的jQuery到我的页面,但当我添加更多的链接/脚本标签,以前的功能jQuery停止运行.有人能帮帮我吗?