【问题标题】:Stimulus Reflex Render Whole Page, Not Reflex-Root刺激反射呈现整个页面,而不是反射根
【发布时间】:2021-01-05 15:23:41
【问题描述】:

在我看来,我使用刺激反射。即使我在父 div 中使用 data-reflex-root,也会重新渲染整个页面。我该如何解决这个问题?

我的代码是这样的;

<div id="pageruleDiv" data-reflex_root="#pageruleDiv" data-controller="PageruleReflex">

      <%= f.fields_for :pagerule do |form| %>
          <div class="inputObj">
              <%= form.label "Action" %>
              <%= form.select "activity", options_for_select(PageRule.activities.map {|k, v| [k.humanize.capitalize, v]}) %>
          </div>
          <div class="inputObj">
              <%= form.label "Method" %>
              <%= form.select "technique", options_for_select(PageRule.techniques.map {|k, v| [k.humanize.capitalize, v]}) %>
          </div>
          <div class="inputObj">
              <%= form.label "Page" %>
              <%= form.text_field :page %>
          </div>
          <a class="btn block text-center w-full no-underline" href="#" id="pageRuleButton" data-reflex="click->PageruleReflex#create"
               >Create</a>
      <% end %>

    </div>

【问题讨论】:

    标签: ruby-on-rails stimulus-reflex


    【解决方案1】:

    要使用的属性是data-reflex-root 而不是data-reflex_root

    https://docs.stimulusreflex.com/morph-modes#scoping-page-morphs

    【讨论】:

      猜你喜欢
      • 2021-01-20
      • 2020-11-01
      • 1970-01-01
      • 2021-01-24
      • 1970-01-01
      • 1970-01-01
      • 2021-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多