Rails link_to与远程锚点:true&方法::post [英] Rails link_to anchor with remote: true & method: :post
本文介绍了Rails link_to与远程锚点:true&方法::post的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
锚由于某种原因无法与方法::post一起使用.
The anchor doesn't work with method: :post for some reason.
我的视图文件index.haml:
My view file index.haml:
/ some code here
%h3= Description
.results
=render 'result_box'
_result_box.haml部分:
_result_box.haml partial:
.row#scroll-here
.col-md-12
= link_to "Get result", get_result_path(@book, :anchor => "scroll-here", parameters: {first: 1, second: 2}), method: :post, remote: true
index.js.erb:
index.js.erb :
$('.results').html("<%= j (render partial: 'result_box') %>")
按link_to并重新加载".results"后,页面焦点仍位于页面顶部.但我希望它位于#scroll-here".
After pressing link_to and reloading ".results" the page focus is still on the top of the page. But I want it to be at the "#scroll-here".
推荐答案
尝试一下
= link_to "Get result", get_result_path(@book, :anchor => "scroll-here", parameters: {first: 1, second: 2}), method: :post,{ remote: true}
或
= link_to "Get result", get_result_path(@book, :anchor => "scroll-here", parameters: {first: 1, second: 2}), method: :post,:remote=> true
请参阅此链接( http://haml.info/docs/yardoc/file.REFERENCE.html#inserting_ruby_ )
这篇关于Rails link_to与远程锚点:true&方法::post的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文