Open badstorm opened 3 years ago
Hi @badstorm,
nope, sorry.
I will not work on this anytime soon. I've did some experiments. As far as I can tell, without jQuery we need to rewrite stuff or depend on third party libraries.
Are you interested in contributing with a PR?
Hi @tagliala, since i need to implement a non jquery version in one of my project I can try to work on it. If you add a branch with your experiments I can take a look and try to work on it (in my free time)
If you add a branch with your experiments I can take a look and try to work on it (in my free time)
I've dropped everything except the code you can see in this comment: https://github.com/ifad/data-confirm-modal/issues/80#issuecomment-778754980
Anyway, I would like to perform the following steps for this gem:
Rails.confirm
I've also found this blog post. Code snippets are licensed under MIT
This is an experimental working version with Bootstrap 5 AND jQuery
In a project that is not using Webpack, added the solution of @tagliala in location vendor/assets/javascripts/data-confirm-modal.js
and replaced:
import jQuery from 'jquery'
import Rails from '@rails/ujs'
import { onDOMContentLoaded } from 'bootstrap/js/src/util/index'
onDOMContentLoaded(() => {
for:
$( document ).on('turbolinks:load', function() {
and it worked.
Hi,
I think it's because
$( document ).on('turbolinks:load', function() {
is being triggered after onDOMContentLoaded
, so Bootstrap had the chance to define modal inside jQuery
I'm trying to rewrite your experiment version in ES6 with no jQuery support. I have a onRails project that use rails-ujs
where we dropped support for jQuery.
But In ES6 modules are imported readonly and so I don't know how to extend the original Rails object ( in particular the Rails.confirm function).
Dose anyone have some suggestion about that? Thanks
@stormenergy91
can you share the error you are getting?
This is my actual file structure:
import Rails from '@rails/ujs'
export class DataConfirmModal
{
constructor()
{
// ..
Rails.confirm = function (message, el ) {
// ...
return true;
}
}
}
I get the error at line Rails.confirm = and the error is Cannot assign to 'confirm' because it is an import.
We should also get rid of Rails.confirm
, there is an interesting gorails episode
https://gorails.com/episodes/custom-hotwire-turbo-confirm-modals
Hi, has anyone already started converting this to Vanilla JS for support for the next Bootstrap 5?