bastinald / laravel-livewire-modals

Dynamic Laravel Livewire Bootstrap modals.
66 stars 31 forks source link

Support for bootstrap 4 #11

Open sbrow opened 2 years ago

sbrow commented 2 years ago

Any chance you could add support for bootstrap 4?

It seems all that needs to change is the javascript that you import:

// modals-bs4.js
let modalsElement = document.getElementById('laravel-livewire-modals');

$(modalsElement).on('hidden.bs.modal', () => {
  Livewire.emit('resetModal');
});

Livewire.on('showBootstrapModal', () => {
  $(modalsElement).modal('show');
});

Livewire.on('hideModal', () => {
  $(modalsElement).modal('hide');
});

Thanks, love the package!

feliperafael commented 2 years ago

I was having trouble upgrading to bootstrap 5 so I used your script. Worked perfectly. Thank you =)

seongbae commented 2 years ago

Where do I put that javascript if you don't mind me asking?

sbrow commented 2 years ago

Where do I put that javascript if you don't mind me asking?

Put it in a separate script and import it after 'bootstrap'.

madurapa commented 1 year ago

Also, you have to modify the modal template a bit to prevent close on the escape key,

  1. publish the view (if you've not already done) php artisan vendor:publish --tag=laravel-livewire-modals:views
  2. modify data attributes to fit the BS v4 (remove extra bs) in resources/views/vendor/laravel-livewire-modals/modals.blade.php

eg: data-bs-backdrop="static" to data-backdrop="static"