### Configure Modal Options with JavaScript Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Pass Bootstrap modal options directly via JavaScript when initializing `confirmModal`. ```javascript $('#foo').confirmModal({backdrop: 'static', keyboard: false}); ``` -------------------------------- ### Direct Confirmation Call (No Rails) Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Use `dataConfirmModal.confirm()` to display a modal with custom options and callbacks. Callbacks `onConfirm`, `onCancel`, and `onHide` are supported. ```javascript dataConfirmModal.confirm({ title: 'Are you sure?', text: 'Really do this?', commit: 'Yes do it', cancel: 'Not really', zIindex: 10099, onConfirm: function() { alert('confirmed') }, onCancel: function() { alert('cancelled') }, onHide: function() { alert('hidden') } }); ``` -------------------------------- ### Add Package (Webpacker) Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Add the data-confirm-modal package using yarn when using Webpacker. ```bash yarn add data-confirm-modal ``` -------------------------------- ### Add Gem to Gemfile (Bootstrap 2.3) Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Use this branch if you are stuck on Bootstrap 2.3. ```ruby gem 'data-confirm-modal', github: 'ifad/data-confirm-modal', branch: 'bootstrap2' ``` -------------------------------- ### Restore Default Settings Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Restore the default settings for the confirmation modal using `dataConfirmModal.restoreDefaults()`. ```javascript dataConfirmModal.restoreDefaults(); ``` -------------------------------- ### Set Global Defaults Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Set global default options for the confirmation modal using `dataConfirmModal.setDefaults`. ```javascript dataConfirmModal.setDefaults({ title: 'Confirm your action', commit: 'Continue', cancel: 'Cancel' }); ``` -------------------------------- ### Autoload jQuery (Webpacker) Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Configure webpack/environment.js to autoload jQuery for Webpacker integration. ```javascript const { environment } = require('@rails/webpacker') const webpack = require('webpack') environment.plugins.prepend( 'Provide', new webpack.ProvidePlugin({ jQuery: 'jquery', }) ) module.exports = environment ``` -------------------------------- ### Basic Rails Link with Confirm Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Use the `:confirm` option in Rails link_to helper to trigger a confirmation modal. ```erb <%= link_to 'Delete', data: {confirm: 'Are you sure?'} %> ``` -------------------------------- ### Configure Modal Options with Data Attributes Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Pass Bootstrap modal options using data attributes on the HTML element. ```html ``` -------------------------------- ### Add Gem to Gemfile Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Add the gem to your application's Gemfile for Sprockets integration. ```ruby gem 'data-confirm-modal' ``` -------------------------------- ### Rails Link with Verification Input Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Add a `data-verify` attribute for extra confirmation. The modal will include a text input for the user to type a verification value. ```erb <%= link_to 'Delete', data: {confirm: 'Are you sure?', verify: 'Foo', verify_text: 'Type "Foo" to confirm'} %> ``` -------------------------------- ### Invoke confirmModal on Element (No Rails) Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Invoke `.confirmModal()` on an element with `data-confirm` attributes. If confirmed, a `click` event is triggered on the element. ```javascript $('#foo').confirmModal(); ``` -------------------------------- ### Require Javascript (Sprockets) Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Require the data-confirm-modal Javascript in your application.js file when using Sprockets. ```javascript //= require data-confirm-modal ``` -------------------------------- ### Require JavaScript (Webpacker) Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Require the data-confirm-modal JavaScript in your pack's application.js file after '@rails/ujs'. ```javascript require('data-confirm-modal') ``` -------------------------------- ### Rails Link with Custom Commit Button Text Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Customize the modal's 'confirm' button text using the `data-commit` attribute. ```erb <%= link_to 'Delete', data: {confirm: 'Are you sure?', commit: 'Sure!'} %> ``` -------------------------------- ### Rails Link with Custom Title Source: https://github.com/ifad/data-confirm-modal/blob/master/README.md Customize the modal's title text using the `data-title` attribute. Falls back to the `title` attribute if `data-title` is not defined. ```erb <%= link_to 'Delete', data: {title: 'Are You Sure?'} %> ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.