-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not work with Turbolinks 5 well #31
Comments
While I'm not using this gem in my Rails 5 app, Bootstrap 4 Hopefully this can help someone else. |
This solution doesn't work for version 1.13.8. Had to disable Turbolinks completely. At any |
I made a sample application that uses version 1.13.8. |
Also didn't work in my case.
|
same issue |
@ledsun's solution is working for:
Also, try adding 'ready' for the
Having both |
It breaks when doing "back" in the browser. |
This is the workaround for going "back": $(document).on('turbolinks:before-cache', function() {
const $picker = $('.selectpicker');
const picker = $picker.data('selectpicker');
if (picker) {
picker.destroy();
$picker.addClass('selectpicker');
}
}); |
@romanbsd Your solution worked for me to an extent, but when navigating my application using Turbolinks, the selectpicker element would appear noticeably later than the rest of the page. My solution ended up using the
|
Thanks man! |
That solution works, but only for one selectpicker. When there are multiple pickers, it is better to handle them all.
But with this solution the problem is that the selected values are lost when going "back". |
This solution helped me out
Hope it will help you to. |
Problem
bootstrap-select depends on the load events of the window.
https://github.com/silviomoreto/bootstrap-select/blob/master/js/bootstrap-select.js#L1840
But the load events of the window is not fired in page transitions with Turbolinks 5.
Reference: snapappointments/bootstrap-select#1413
Resolve
We relay the 'turbolinks:load' events of the document to the load events of the window.
For example:
Suggestion
I think it is a good idea to append above code into the vendor/assets/javascripts/bootstrap-select.js in this gem.
Because this gem is to use bootstrap-select with the Ruby on Rails.
The text was updated successfully, but these errors were encountered: