Data Confirm Modal

screenshot of Data Confirm Modal

Makes Rails' link_to confirm: 'foo' build a Bootstrap Modal instead of calling the browser's confirm() API.

Overview

The Data-Confirm ModalGem is a powerful tool that enhances user interactions by integrating Bootstrap's modals as an alternative to the traditional browser confirm dialog. This gem is particularly beneficial for applications built with Rails, allowing developers to implement more visually appealing and customizable confirmation dialogs for links and actions that require user consent. With features such as user input verification and customizable titles and button texts, it ensures a seamless experience while reducing the risk of accidental actions.

The gem's simplicity allows for effortless integration with existing Rails helpers through the :confirm option, transforming all links with the data-confirm attribute into Bootstrap modals. This innovation not only modernizes the confirmation process but also gives users greater clarity and control over their interactions.

Features

  • Bootstrap Compatibility: Supports both Bootstrap 3 and 4, allowing for modern styling in confirmation dialogs.
  • Customizable Titles: Modify the modal’s title using the data-title attribute, or fall back to the title attribute if not defined.
  • Enhanced Confirmation: Includes a data-verify attribute for an additional text input, prompting users to confirm their actions explicitly.
  • Flexible Integration: Works with various elements like <a>, <button>, and <input[type="submit"]> by default.
  • Global Settings: Utilize dataConfirmModal.setDefaults for consistent configuration across all modals, with the option to restore defaults easily.
  • Custom Confirmation Messages: Modify the 'confirm' button text dynamically using the data-commit attribute for improved user experience.
  • Callback Functions: Implement onConfirm and onCancel callbacks for handling user responses effectively during modal interactions.
  • JavaScript Control: Options can be set through JavaScript or data attributes, providing flexibility based on developer preferences.