Skip to content

Instantly share code, notes, and snippets.

@ytyng
Last active July 3, 2018 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytyng/2991dfbfa909cc22250056ddf0afce90 to your computer and use it in GitHub Desktop.
Save ytyng/2991dfbfa909cc22250056ddf0afce90 to your computer and use it in GitHub Desktop.
/**
* popover confirmation
*/
(function () {
let $formPopoverConfirm = $('form.popover-confirm');
if (!$formPopoverConfirm.length) {
return;
}
$formPopoverConfirm.on('submit', function () {
let $this = $(this);
let $content = $('<div>');
let $executeButton = $('<button>', {
addClass: 'btn btn-primary btn-block',
text: '実行する',
});
let $cancelLink = $('<div>', {
addClass: 'text-center mt-2',
html: $('<a>', {
text: 'キャンセル',
attr: {
href: '#',
}
})
});
$content.append($executeButton);
$content.append($cancelLink);
$this.popover({
title: '実行していいですか?',
content: $content,
html: true,
placement: 'bottom',
}).popover('show');
$executeButton.on('click', function () {
$this.off('submit');
$this.submit();
$this.popover('hide');
return false;
});
$cancelLink.on('click', function () {
$this.popover('hide');
return false;
});
return false;
})
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment