
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
simple-dialog
Advanced tools
A simple dialog component for the browser.

var SimpleDialog = require('simple-dialog');
var dialog = SimpleDialog({
template: '<h1>HEADER</h1>'
});
// open dialog
dialog.open(function(returnValue) {
console.log('dialog closed with', returnValue);
});
// close with value
dialog.close({ foo: 'BAR' });
The dialog constructor accepts the following configuration options:
{Boolean} [backdrop=true] if false, do not show backdrop
{Boolean} [closable=true] if false, do not close via close control/backdrop
{String} [id] an id to assign to the dialog
{Element|String} [parent='body'] the parent node to attach the dialog to
{Element|String} [template] the element to display as the dialog content
{String} [className=''] classes to add to the .dlg element
open([closeFn])close([resultValue])toggleClass('class list')element: DOMElementThe dialog is built from the following template:
<div class="dlg">
<div class="dlg-body">
<a class="dlg-close" href>×</a>
<div class="dlg-content"></div>
</div>
</div>
Default styling can be found in the less/dialog.less file.
The dialog will attach itself to its dom node via the dialog property once it is attached to the document tree.
SimpleDialog({
id: 'how-are-you',
template: 'How are you?'
});
setTimeout(function() {
SimpleDialog('#how-are-you').close();
}, 2000);
The dialog will close on elements annotated with .dlg-close.
A custom close result can be provided via the dlg-close-result attribute
on .dlg-close elements.
SimpleDialog({
id: 'how-are-you',
template: '<button class="dlg-close" dlg-close-result="foo">FOO</button>'
});
The dialog is an EventEmitter. Extend it by hooking into one of the following life-cycle events:
attach(parentElement) attached to parentElement
pre-open about to open
open dialog is open
pre-close(resultValue) about to close with returnValue
close(resultValue) dialog closed with returnValue
detach(parentElement) detached from parentElement
The this argument inside an event listener will always refer to the respective dialog instance:
SimpleDialog({ template: 'HUUUU!' }).on('pre-open', function() {
var dialog = this;
setTimeout(function() {
dialog.close('timeout, haha!');
}, 2000);
});
Use the life-cycle events in order to make it fit into your favourite front-end library. An example integration into AngularJS can be found here.
MIT
FAQs
A simple dialog component for the browser
We found that simple-dialog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.