hut-modal
intro
A simple HTML modal module that displays a simple dialog prompt. It contains a minimum amount of styling so that you can customize it to your needs. See the example to see it in action.
usage
- Install using npm -
npm install --save hut-modal
- Import styling using rework-npm -
@import "hut-modal";
- Load JS using browserify -
var modal = require('hut-modal');
code
My Modal See my modal? Yes No
var modal = ; var m = ; // When a [data-result] element is clicked, it will hide the modal and trigger// the result event:m; myModal;
reference
modal(element)
Creates a new Modal
object that manages the modal specified by element
. The
element must have a similar structure as the example above.
#show()
Shows the modal. Note that the element must be already attached to the document for it to be shown.
#hide()
Hides the modal.
show()
Event: Triggered immediately after the modal is shown.
hide()
Event: Triggered immediately after the modal is hidden.
result(value)
Event: Triggered when an element with the data-result
attribute is clicked. The
modal will be automatically hidden and value
will be the value of the
data-result
attribute of the element that was clicked.