Introducing Loadjs

Wolox Engineering
Wolox
Published in
1 min readJan 27, 2015

Today we released a new version of our Loadjs gem. This gem allows users to include page specific Javascript code in their Rails application without losing all the magic provided by sprockets.

So after installing the gem you can include a page’s specific Javascript right away. For example, let’s say that you want to execute a piece of code only for the ‘foo’ controller and ‘bar’ action. You can do it like this:

You can also use a hash option instead of the string to set the controller and the action.

This allows users to omit the action option which will execute the function for all actions of the given controller. For example, if you want to execute a piece of code for all the actions of the ‘foo’ controller you can do it like this:

Finally, you can also specify several controllers and actions. For example:

This will show an alert for the actions ‘action_1', ‘action_2' and ‘action_3' of the controller ‘controller_1', the action ‘action_1' of the controller ‘controller_2' and all the actions of the controller ‘controller_3'.

Hope you find this useful. We would like to hear your feedback and pull requests!

Posted by Guido Marucci Blas(guidomb@wolox.com.ar)

www.wolox.com.ar

--

--