1.2.1 • Published 6 years ago
@rannk/jquery-simple-modal v1.2.1
installation
You can install with npm:
npm install @rannk/jquery-simple-modal
or
download js file from github
Opening
Method 1: Automatically attaching to links
The simplest approach is to add rel="modal"
to your links and use the href
attribute to specify what to open in the modal.
Open an existing DOM element by ID:
<div id="myModal" class="modal">
...
</div>
<a href="#myModal" rel="modal">Login</a>
Method 2: Manually
$('#myModal').modal("show");
Options
These are the supported options and their default values:
$.modal = {
panel: window, // Set in which layer to display the modal
clickClose: true, // Allows the user to close the modal by clicking the overlay
};
Events
we support these events during Modal cycle (open/close).
$.modal.beforeOpen // Fires just before the modal opens.
$.modal.open // Fires after the modal has finished opening.
$.modal.beforeClose // Fires when the modal has been requested to close.
$.modal.afterClose // Fires after the modal has fully closed
So, you can do this
// create event function before modal open
$.modal.beforeOpen = function(modal) {
...
}