Skip to content

Make work with turbolinks and better helper #2

@justin808

Description

@justin808
  • Change JS code (maybe in the helper) so that it renders on event page loaded or page change
  • Reenable turbolinks so that big JS file only loaded once.
<!-- props should be set in the controller -->
<% props = { helloWorldData: { name: "Prop from Rails!" } } %>

<!--TODO MOVE THIS to one helper method react_component("App", props) -->
<!-- This sets the props for the client side app -->
<!-- Get the id tag by taking lower case version of component name -->
<!-- Offer option to put in props -->
<%= javascript_tag "window.__DATA_FROM_RAILS__ = #{props.to_json};" %>
<div id="app"><%= react_component("App", props) %></div>

spec/dummy/app/views/layouts/application.html.erb:16

<!DOCTYPE html>
<html>
<head>
  <title>Dummy</title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <!-- TODO PUT THIS BACK!!!!-->
   <!--javascript_include_tag 'application', 'data-turbolinks-track' => true -->
  <%= csrf_meta_tags %>
</head>
<body>

<%= yield %>
<!-- TODO: Move back to inside HEAD section. Address loading document ready (page loaded
           considering the use of turbolinks.
-->
<%= javascript_include_tag 'application' %>

</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions