Closed dcecile closed 6 years ago
To clarify, in rails-ujs
this is no longer $.rails
but window.Rails
.
You can't rely on $.rails
because it will be undefined if rails-ujs
is included before jquery
, which is possible because rails-ujs
does not depend on jQuery.
One option is to use (window.Rails || $.rails)
instead.
Hi, sorry for the delay. I've pushed the sensible, suggested change, that should fix this issue. If all is well I can cut a new release.
I've tried out the fix and it looks good to me.
Before the fix (with rails-ujs
before jquery3
), data-confirm-modal
failed to load, resulting in native modal popups. After the fix, data-confirm-modal
loaded fine, and I get Bootstrap modal popups. :+1:
(Continued from https://github.com/twbs/bootstrap-rubygem/issues/127...)
In integrating
data-confirm-modal
into my Rails app, I accidentally used this ordering in myapplication.js
file:With this ordering
data-confirm-modal
doesn't perform Rails initialization, because$.rails
wasn't set. I resolved the issue by moving the//= require jquery3
to the top. With jQuery included first,data-confirm-modal
initialized without any problems.I had originally created this as a documentation issue for
bootstrap-rubygem
(which explains theapplication.js
setup), but @glebm has suggested that this be resolved by changingdata-confirm-modal
to stop using$.rails
.What do you think? Would an alternative to
$.rails
help make the initial setup ofdata-confirm-modal
easier?