ifad / data-confirm-modal

Makes Rails' link_to confirm: 'foo' build a Bootstrap Modal instead of calling the browser's confirm() API.
MIT License
270 stars 115 forks source link

Both the modal and the confirm-window are displayed on IE11. #80

Open mya-zaki opened 4 years ago

mya-zaki commented 4 years ago

Two windows are displayed when you click the link that has a data-confirm attribute. Please see below.

issue_ie11

Versions:

tagliala commented 3 years ago

Hi,

apologies for the late reply.

I can confirm the issue. It ~only happens when using webpacker~

Edit: It happens when using @rails/ujs instead of jquery-ujs, even without webpacker

Demo: https://jsbin.com/lejopuq/

tagliala commented 3 years ago

@vjt with latest versions @rails/ujs, it is possible to override Rails.confirm.

Instead of

https://github.com/ifad/data-confirm-modal/blob/139459fb5be2821818bcb138460919aee5d8b1b5/vendor/assets/javascripts/data-confirm-modal.js#L315-L355

we could write:

/**
 * Override `Rails.confirm` dialog.
 *
 * If the modal is visible, it means that the handler is being called by the
 * modal commit button click handler, as such the user has successfully
 * clicked on the confirm button.
 *
 * If the modal is not visible, then it is spawned and the default Rails
 * confirmation dialog is canceled.
 *
 */
Rails.confirm = function (message, el) {
  const modal = $(el).getConfirmModal()

  if (modal.is(':visible')) {
    return true
  } else {
    modal.spawn()
    return false
  }
}

It also works on IE11, FWIW