Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We use Ruby on Rails so we have a clear controller/action pair, we use this to reference both CSS classes and Javascript views. </p> <p>Specifically, grab the name of the controller+action name and embed this as a ID in the view, put it on the body tag or your main content div. </p> <pre><code>&lt;body id="users_list_body"&gt; </code></pre> <p>Where "users" is the name of the controller, "list" is the action. Then in your CSS you have rules likes</p> <p>#users_list_body</p> <p>So you can scope all of your specific CSS to that view. Of course, you also have more general CSS to handle overall styling. But having this ID defined more easily allows you to create specific CSS for individual pages (since a controller/action maps to a specific page).</p> <p>You end up having rules like this</p> <pre><code> #users_list_body table #users_list_body table thead </code></pre> <p>Do the same for Javascript. So in the footer of every page you take your same controller/action name pair and embed it in a function call</p> <pre><code> //javascript if(V.views.users_list) { V.views.user_list(); } </code></pre> <p>Then in your external Javascript you have something like</p> <pre><code>V = {}; V.views = {}; V.views.user_list = function() { //any code you want to run for the Users controller / List action.. //jQuery or something $('#save_button').click({ ... }); } </code></pre> <p>with all of your Javascript code scoped to a specific function, it ends up being all encapsulated. You can then combine all of your Javascript files into one, compress it and then serve it up as one file and none of your logic will conflict. One page's JS will not conflict with any other page's JS because each page is scoped by its method name.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload