我想在durandal.js中添加comfirmationbox
我写了下面的代码,但没有返回是或否
define(['services/logger', 'durandal/plugins/router', 'durandal/app'], function (logger, router, app) {
if (app.showMessage('Are you sure you want to delete :' + titlename + '?', 'Delete Confirmation', ['Yes', 'No'])) {
DeleteAchievement(self, obj.Soid)
}
最佳答案
showMessage方法返回一个Promise,因此您的代码应如下所示:
app.showMessage('Are you sure you want to delete :' + titlename + '?', 'Delete Confirmation', ['Yes', 'No']).then(function(dialogResult){
if(dialogResult === "Yes"){
//Your code
}
});
您可以在此处获取更多信息:http://durandaljs.com/documentation/Showing-Message-Boxes-And-Modals/
关于javascript - durandal.js确认框无法返回是或否,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18507679/