Closed dbarison closed 6 years ago
@dbarison
$(document).on "turbolinks:load", -> $('#modal1').modal()
I'm having a similar problem. It works if it is the first page load. However, if you navigate away and back to a page containing a modal it will not trigger the second time. :/ I'm using the turbolinks:load
event listener.
Manually adding JQuery to trigger the modal opening works for me:
$(document).on('turbolinks:load', function() {
$('.modal').modal();
$('.modal-trigger').on('click', function() {
$('.modal').modal('open');
})
})
With that said, this seems like a workaround, and I'm wondering if there should be another JQuery event we are listening to in addition to turbolinks:load
that would fix this problem.
@basicBrogrammer, I was having pretty much the same problem and managed to fix it by resetting Materialize's modal count before initializing the modals:
$(document).on('turbolinks:load', function() {
M.Modal._count = 0;
$('.modal').modal();
});
the resetting model count works for me
Thanks @arthurlinhares it works...
Thank you! so much worked like charm
<button data-target="modal1" class="btn modal-trigger">Modal</button>
this doesn't work with turbolinks. Modal doesn't open