我正在尝试使用history.pushState显示URL。在我的 即使我的警报也没有运行此代码。 这就是我想通过点击功能实现的目标: 如您所见,我正在尝试访问其中具有数据远程功能的锚标记,但它不起作用。 我想要获得的预期输出是,每当我单击一个分页时,它都必须在顶部的URL栏中显示 我如何进行这项工作? 答案 0 :(得分:0) 尝试这样assets/javascript/application.js
内放置ff代码:$(document).on('click', '.pagination a.page-link[data-remote=true]', function(){
alert('voila');
history.pushState({}, '', $(this).attr('href'));
});
http://localhost:3000/contacts?page=2
之类的页码。1 个答案:
window.history.pushState(history.state, null, $(this).attr('href'));