yiisoft/yii2 — pull request #3511 by tanakahisateru (2014-05-19 17:04:55+00:00)
Title: Change data-confirm dialog implementation to callback style.

To create custom dialog for `yii.confirm`, current design is so inconvenient.

JSe's standard `confirm()` function can block event handling until user input. But most of custom modal UI (for example using Bootbox.js http://bootboxjs.com/) can't control script processing. I suggest to change handling `data-confirm` and `data-method` from return-style to callback-style.

I've succeeded to create my dialog box using Bootstrap's Modal component by my callback version.

```html

×

Cancel
OK

```

```javascript
var $confirmModal = jQuery("#my-confirm");

$confirmModal.find(".confirm-ok").on("click", function() {
var action = $confirmModal.data("ok-action");
if (action !== undefined) {
$confirmModal.on("hidden.bs.modal", function() {
$confirmModal.off("hidden.bs.modal", arguments.callee);
action();
});
}
$confirmModal.modal("hide");
});

yii.confirm = function(message, action) {
$confirmModal.find(".modal-body p").text(message);
$confirmModal.data("ok-action", action);
$confirmModal.modal("show");
};
```