Closed sondh5 closed 5 years ago
I am using select2 with ransack to multiple searching but it got a big problem.
My js file: search.js $(document).on("turbolinks:load", function () { $("#q_city_matches_any").select2({ placeholder: I18n.t("js.city") }); });
search.js
$(document).on("turbolinks:load", function () { $("#q_city_matches_any").select2({ placeholder: I18n.t("js.city") }); });
My slim: index.html.slim
index.html.slim
p.form-group= f.select :city_matches_any, @cities, {}, {class: "form-control", multiple: true}
application.js
Its oke in normal case but problem happens when I move from index page to other page and click button back of browser to back to index page.
Normal case: https://gyazo.com/9ea59e58e5271cd27ff716e548f51f17 Issue: https://gyazo.com/3d8826be1b4f028760618e83e8d7b9cf
Thank you for your support!
@hongsondhs can try with https://github.com/kossnocorp/jquery.turbolinks ? pls
Hello! I Have same problem on rails 5. jquery.turbolinks is deprecated, this gem does not work with Turbolinks 5+
This works for me:
$(document).on("turbolinks:before-cache", function() { $('.select2-input').select2('destroy'); }); (document).on('turbolinks:load',function(){ $('.select2-input').select2(); });
Details here
I am using select2 with ransack to multiple searching but it got a big problem.
My js file:
search.js
$(document).on("turbolinks:load", function () { $("#q_city_matches_any").select2({ placeholder: I18n.t("js.city") }); });
My slim:
index.html.slim
p.form-group= f.select :city_matches_any, @cities, {}, {class: "form-control", multiple: true}
application.js
Its oke in normal case but problem happens when I move from index page to other page and click button back of browser to back to index page.
Normal case: https://gyazo.com/9ea59e58e5271cd27ff716e548f51f17 Issue: https://gyazo.com/3d8826be1b4f028760618e83e8d7b9cf
Thank you for your support!