-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Duplicate selectpicker with turbolinks #1413
Comments
A simple fix will just select the selectpickers which do not have the
|
@Startouf This removes the duplicate, but renders the selectpicker unbinded - clicking/selecting no longer works... at least for multiselect. |
Oh sorry about that, I don't use multiselect in the website I'm working on so I didn't check for bugs on that side. Any idea what causes that ? |
I think it only affects Tubolinks v5.0.x. Having created a new Rails 4.2 test app with the default version of turbolinks (2.53), back/forward works perfectly. But as soon as you update your gemfile to:
.. Then that's when the duplicates appear. Adding your suggestion fixes the duplicates but makes selectpicker unresponsive:
Test app: then: http://localhost:9999/users/1/edit, click on 'Test link', then press the back button. Will have a bit more of a look tomorrow. |
OK, found a temporary(?) solution to this problem, needed to replace the contents of .bootstrap-select with .selectpicker then re-initialise selectpicker:
|
Even better, using the Turbolinks 5
|
@aperkins81 It doesn't work for turbolinks 5.0.0 |
My solution: document.addEventListener 'turbolinks:load', ->
$(".selectpicker").selectpicker()
document.addEventListener 'turbolinks:before-cache', ->
$('.selectpicker').selectpicker('destroy').addClass('selectpicker')
|
I was able to get around this altogether by invoking the plugin this way: $(document).on('turbolinks:load', function() {
$(this).trigger('load.bs.select.data-api');
}); This preserves the auto-initialization behavior described in the README:
|
@MaffooClock I like your solution, but I had to use |
This is the solution that works perfectly for me:
Update Even better and more precise:
|
Same thing happened to me using materialize, and i made this fix for that, hope it helps: HTML Code (with bug):
JS Code (fixes html code with bugs above):
Final result:
|
I tried everything commented here, but it didn't work. I was able to get around this altogether by not caching the page with the select. I used this on the top of the page with select:
|
2019 and no fix for this? |
I used a combination of @matheussilvasantos and @ledsun and it work for me. |
2021, we think about Mars, but we can not fix js ;) hahha |
Turbolinks is no longer under active development. |
Using turbolinks 5, I am observing duplicate pickers when playing with the browser history
I am using a global
$('.selectpicker').selectpicker('refresh');
The pickers are actually nesting into each other
The text was updated successfully, but these errors were encountered: