简体   繁体   English

带有轨道的pjax

[英]pjax with rails

I am using rack-pjax gem as described in the railscasts playing with pjax 我使用的机架pjax宝石作为railscasts描述与pjax打

But the issue i am having with my layout is, i have some dynamic generated links and page headings on top of the main 'yield' call in the application layout. 但是我的布局存在一个问题,就是在应用程序布局的主要“ yield”调用之上,我有一些动态生成的链接和页面标题。 Those links will be generated dynamically based the main yield. 这些链接将基于主要收益动态生成。 Though i am putting the dynamically loaded part in the data-pjax-container, that part is still not coming(being invisible). 尽管我将动态加载的部分放在data-pjax-container中,但是该部分仍然没有来(变得不可见)。 I guess that is because of the way pjax works, when ever a pjax request goes to the server, it will carry a 'X-PJAX' header and the server doesn't load the whole layout if it finds the X-PJAX in the headers. 我想这是因为pjax的工作方式,无论何时有pjax请求发送到服务器,它都会带有一个“ X-PJAX”标头,并且如果服务器在服务器中找到X-PJAX,则服务器不会加载整个布局。标头。

%div{:id = "content", :data => {"pjax-container" => true}}

  #context_menu
    = THE DYNAMICALLY GENERATED CONTENT GOES HERE
    .clear

  #pageHeading
    #breadcrumbs
      = THE DYNAMICALLY GENERATED CONTENT GOES HERE
      .clear


    .bodytext
      = yield   / THIS IS THE MAIN YIELD
    .clear

Any suggestions to get around this please.. 有什么建议可以解决这个问题..

您可以通过明确告诉rails哪些链接应该在视图中进行pjax调用来解决此问题,而不是使用隐式pjax标头,例如:

<%= link_to 'user', user_path, :'data-pjax' => '#id_of_target_pjax_container' %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM