As Refereed to Rails 5 Amazing Features
Turbolinks has been part of Rails since version 4, probably one of the features that people hate or love; there is no middle place.
With Rails 5, we’ll get a new version that, with the help of HTML5 user data attributes, will expect better speed and rendering in our Rails applications.
The most important change in this new version is the partial replacement feature. On the client side, we will be able to tell Turbolinks what content we need to change / replace and what we do not.
Turbolinks will look for custom HTML5 attributes and decide on a replacement strategy in ours.
To trigger a replacement on the client side, we could use or update our version. The difference between and lies in the fact that the first of them will give the server to receive HTML code, which should be used to replace ours, expecting from us HTML code that should be used for its operation.
With both functions, we can pass a hash with an array of HTML elements or.
Action Result Turbolinks.visit(url, { change: ['entries'] }) Will replace any element with custom attribute and any element with its id listed in change. Turbolinks.visit(url) Will keep only elements with custom attribute and replace everything. Turbolinks.visit(url, { keep: ['flash'] }) Will keep only elements with custom attribute and any element with its id listed in keep, everything else will be replaced. Turbolinks.visit(url, { flush: true }) Will replace everything
We can run the same functionality from the server side, and both can receive as options, but can also receive with or for forced redirection with or without Turbolinks.
If you like Turbolinks or not, this may be the right time to try and find out if it might be suitable for your application.
Sumit munot
source share