在Firefox 25.0中,canDeactivate方法中的MessageBox引发错误

时间:2013-10-08 08:22:44

标签: javascript firefox durandal

这在Firefox 25.0中失败但在Chrome和IE 11中没有问题:

 var canDeactivate = function () {
    if (hasChanges()) {
        console.log(customer().CustomerID() < 0);
        var msg = customer().CustomerID() < 0 ?
            'Are you sure you want to discard the customer - "' + customer().CustomerName() + '" ?' :
            'Are you sure you want to discard the changes\n for the the customer - "' + customer().CustomerName() + '" ?';
        var title = 'Confirm navigation';
        return app.showMessage(msg, title, ['Yes', 'No'])
            .then(confirmDelete);

        function confirmDelete(selectedOption) {
            if (selectedOption === 'Yes') {
                return true;
            }
            else {
                return false;
            }
        }
    }
    else {
        return true;
    }
};

在Firefox 25.0中,它会在评估来自消息框的响应之前抛出一个ReferenceError,它在不调用函数confirmDelete的情况下取消导航。

有什么问题?

1 个答案:

答案 0 :(得分:0)

在return语句之前声明function confirmDelete() {...}解决了问题。