-
Notifications
You must be signed in to change notification settings - Fork 65
Does not work with Rails 5 / Turbolinks 5 #56
Comments
+1 |
1 similar comment
👍 |
Motioning to deprecate this gem and not implement support for rails 5. On Friday, March 25, 2016, Andrea Dal Ponte [email protected]
|
If this is deprecated, what should we use instead? Change our listeners to |
Personally, I would love the rails 5 support 😃 |
This seems to work, add after requires in application.js: Except I'm getting some leftover js validation errors after re-visiting a form. But it quickly resets after load. Edit
Bottom of <%= content_for?(:head) ? yield(:head) : '' %> Form views: <% content_for :head do %>
<meta name="turbolinks-cache-control" content="no-cache">
<% end %>
Bottom of application.js: var resetForms = function () {
// this depends on your use
// this is for foundation 6's abide
$('form').each(function () {
$(this).foundation('destroy');
});
};
document.addEventListener("turbolinks:before-cache", function() {
resetForms();
}); |
i added a work around, |
Sorry, I'm not involved into Turbolinks world for three years already (I'm a React-hipster ¯_(ツ)_/¯) and it's hard to me to make an adequate conclusion regarding depreciation issue. I completed trust @rstacruz, but I'll love to see jQuery Turbolinks moving forward while there are users. If there are people who want to take control over the project, please welcome (on any your conditions). |
jQuery Turbolinks simply makes As of Turbolinks 5, teardowns need to happen on turbolinks:before-cache. Making jQuery Turbolinks work with Turbolinks 5 is not going to be simple. jQuery Turbolinks's reason-for-living is these two things, as far as I'm concerned:
As for (1), the additional abstraction isn't worth the small benefit of a few less bytes to write. As for (2), well, they're legacy... the responsibility to make them Turbolinks compatible should probably be better handled in those projects rather than a shim. With that said, it should be easy to make jQuery Turbolinks work for TL5 by simply changing the event names, as others have noted. However, you'll likely run into some problems along the way as a result of the concerns above. |
I'd like to offer an alternative to make jQuery + Turbolinks a little easier to deal with: It isn't a replacement for jquery.turbolinks, but it may address some of the reasons you might want to use jquery.turbolinks in the first place. |
@rstacruz it's possible to re-build |
@kossnocorp I'm not sure that's possible... the two of them work rather differently. |
Thanks for the link. So what I need to do for the form validation is destroy on |
We recently implemented turbolinks 5 at work and this https://github.com/wshostak/turbolinks-jquery is the solution we came up with for dealing with jQuery on and ready. It allowed us to keep working with our current jQuery scripts/ plugins with out having to make changes to them. Thought I would share since seems like a few others like us could use it. |
I wrote an easy solution here: Basically add this file: |
@Lowryderch that worked for me, using Rails 5 and Turbolinks 5 - Thanks a lot 💃 |
This is my solution, override
|
@Lowryderch it works on local environment, but somehow doesn't work on staging/production environment. Turbolinks 5.0.1 any suggestion will be appreciated |
@wshostak solution worked for me. But I updated the code to handle events that are not String type( I encounter problem with datepicker ).
|
Something that I did which seems to make them work properly on Rails 5 is the following:
Not sure if this is a recommended way to do things, but it seems to work by putting the listener on. I am running Rails 5.0 and turbolinks 5.0 in my gemfile. |
Some application javascript (e.g., Ace Editor) did not load initially and a page reload was necessary every time. It seems that the migration to `turbolinks:load` with Turbolinks version >=5 caused several issues on loading javascript and firing events: * Turbolinks 5 discussion: kossnocorp/jquery.turbolinks#56 * Fixes bindings on `ready` event: https://github.com/wshostak/turbolinks-jquery * Compatibility script: https://github.com/turbolinks/turbolinks/blob/master/src/turbolinks/compatibility.coffee Removes the `page:load` listeners by replacing: `$(document).on('ready page:load', function () {` with `$(document).ready(function () {` Removing all turbolinks related code fixed this issue.
It looks like the latest version of Turbolinks doesn't use the same event names as before, causing this gem to not work with Rails 5.
The text was updated successfully, but these errors were encountered: