0

I am a super newbie to rails but I am defining a local variable (a css class) and passing it to this partial

render(partial: 'calendar_inventory', locals:{klass: params[:select]})

Inside my partial I have a pagination occurring:

  <div class="grid-container" data-calendar-target="grid" data-action= "scroll->calendar#populateHeader">
    <%= turbo_frame_tag "paginate_page_#{@sub_orders.current_page}" do %>
      <%@sub_orders.each do |sub| %>
        <%="klass:"+klass%>
      <%end%>
      <% if @sub_orders.next_page %>
        <%= turbo_frame_tag "paginate_page_#{@sub_orders.next_page}", src: filter_supplier_calendars_path(page: @sub_orders.next_page), loading: 'lazy' do %>
          Loading...
        <% end %>
      <%end%>
    </div>
  <% end %>
<%end%> 

Trying to paginate some orders here, the initial loading of the klass is found however when I paginate is does not keep the value of klass and therefore doesn't display anything.

I've tried adding locals:{klass: params[:select]} to where the next_page is being appended but it just adds a data-variable of locals="klass" inside the tag itself

Any ideas on how I can pass this klass variable into the turbo frame?

Chiperific
  • 4,428
  • 3
  • 21
  • 41
  • it looks as if you need to pass the value of the `select` parameter in the url for the turbo_frame_tag src attribute, maybe as a query string, `filter_supplier_calendars_path(page: @sub_orders.next_page, select: klass)` – Les Nightingill Jul 26 '22 at 18:24
  • Can you post the code from the related controller? Only seeing the view makes this tough to follow. – Chiperific Aug 15 '22 at 04:29
  • Actually Les already answered it I just dont know how to mark it answered im sorry! – Tyler Riehl Aug 16 '22 at 06:19
  • Either @LesNightingill can post their solution as an answer and Tyler can accept it. Or Tyler can post an answer and accept it as the solution (I think after a waiting period). – Chiperific Aug 16 '22 at 13:17

0 Answers0