[英]Can't get pjax to work on Rails
I'm trying to get pjax to work on a Rails app but none of the links are being annotated with pjax. 我正在尝试让pjax在Rails应用程序上工作,但是pjax都未注释任何链接。 I think pjax isn't really being loaded.
我认为pjax并未真正加载。 I'm using pjax_rails and am basically following the railscast instructions but using
//= require jquery.pjax
instead of just pjax
. 我正在使用pjax_rails,基本上遵循了railscast的说明,但是使用
//= require jquery.pjax
而不是pjax
。 I'm also using it with bootstrap which may cause an issue but I'm not sure. 我也在引导程序中使用它,这可能会引起问题,但我不确定。 My other thought is that is that the pjax javascript isn't being loaded and I need to run something like
$('a').pjax('[data-pjax-container]')
我的另一个想法是未加载pjax javascript,我需要运行类似
$('a').pjax('[data-pjax-container]')
To be clear the main problem is that pjax isn't being loaded client side and thus when I make requests the X-PJAX header is not being set. 要明确的是,主要问题是客户端未加载pjax,因此,当我发出请求时,未设置X-PJAX标头。
Finally got it working. 终于成功了。 First problem was that the unbeknownst to me the assests pipeline was turned off so the pjax javascript file wasn't being included.
第一个问题是我不知道的assasss管道已关闭,因此未包含pjax javascript文件。 Instead I went with the pjax rack gem and dumped it into the public directory.
相反,我使用了pjax机架gem并将其转储到公共目录中。 Then I created a new javascript file with
$('a').pjax('[data-pjax-container]')
and it works! 然后我用
$('a').pjax('[data-pjax-container]')
创建了一个新的javascript文件,它可以正常工作! Although I'm not sure why I need to manually call that javascript when all the documentation seems to point to the fact that it should be already there. 尽管我不确定为什么所有文档似乎都指向它应该已经存在的事实时,为什么需要手动调用该javascript。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.