我正在使用Rails 4
并想使用内置Turbolink
宝石.我很满意它所做的一切,除了我希望它在每个页面请求时重新加载一个js文件.
换句话说,我想要一个特定的js文件来忽略turbolinks,我该怎么做呢?
如果你有一个不断渲染/销毁的HTML元素,那么对HTML的javascript事件绑定是否仍然存在,或者是否需要在创建/销毁周期中绑定/取消绑定事件?
我正在使用D3来生成美国各县的地图.另外,我正在生成工具提示覆盖,其中包含点击事件上的按钮以进行有效选择.
click事件处理程序的一部分,我将模板的HTML绑定到tooltip元素,然后将javascript事件处理程序绑定到所述HTML
thisObj._tooltip.template = template : "<div id = 'tooltip_template'>" +
"<div class = 'county_data'></div>" +
"<img src = '/static/images/delete.png' width = '28' height = '28' class = 'delete_logo' id = 'close_tooltip' />" +
"<button id = 'add_prospective_market' class = 'tooltip_button'>Prospective Market</button>" +
"<button id = 'add_market' class = 'tooltip_button'>Market County</button>" +
"<button id = 'remove_market' class = 'tooltip_button'>Remove Market</button></div>"
thisObj._tooltip.tooltip.html(thisObj._tooltip.template)
.style("left", (d3.event.pageX + 10) + "px")
.style("top", (d3.event.pageY - 50) + "px")
.style("pointer-events" , "auto")
.style("width", "400px")
.style("height", …
Run Code Online (Sandbox Code Playgroud)