A version of the uikit dialog box written in pure javascript, with structural styling. This widget is useful for requesting confirmation in deleting or altering important information. For embedding html into a dialog, try bmcmahen/modal
.
$ npm install -g component
$ cd myComponents
$ component install bmcmahen/confirmation
$ component build
show
the dialog is shown.hide
the dialog is set to hide.hidden
the dialogue is hidden after the (optional) animation.cancel
the (optional) cancel button was pressed.okay
the (optional) okay button was pressed.
With the default template, attributes available include:
confirmation({
title: 'your title',
content: 'your content',
okay: 'your okay button text',
cancel: 'your cancel button text'
});
If you precompile your own template and pass it into the options attribute you can also include any additional attributes that are contained within your template.
Show dialog.
Hide dialog.
Include it before show()
to animate it. Options include slide
, fade
, and scale
.
Is called when the okay button
is pressed. Example:
confirmation({okay: 'okay'}).ok(function(e){ console.log('okay was pressed ')});
Same as confirmation#okay, except for the cancel
button.
Add a class name to the dialog.
var c = require('bmcmahen-confirmation');
var trigger = document.querySelector('button')
, confirmation;
trigger.onclick = function(){
confirmation = c({
title: 'hi',
content: 'hello',
cancel: 'Cancel',
okay: 'Delete'
}).effect('fade')
.show()
.okay(function(e){
console.log('Delete it.');
})
.cancel(function(e){
console.log('cancel it.');
});
};
MIT