Dojo开发之实现confirm功能

废话少说 直接上代码

 function raiseQueryDialog_custom_callbacks(title, question, callbackFn) {

        var errorDialog = new dijit.Dialog({ id: 'queryDialog', title: title });

        //显示框
        errorDialog.attr('content', question + "" +
                    "<button dojoType='dijit.form.Button' id='yesButton'>确定</button>" +
                    "<button dojoType='dijit.form.Button' id='noButton'>取消</button>");
        errorDialog.startup();
        var yesButton = dijit.byId('yesButton');
        var noButton = dijit.byId('noButton');

        //如果点击确定按钮
        dojo.connect(yesButton, 'onClick', function(mouseEvent) {
            console.debug("yesCallback here!");
        errorDialog.hide();
        errorDialog.destroyRecursive();
        callbackFn(true);
        });

        //如果点击取消按钮
        dojo.connect(noButton, 'onClick', function(mouseEvent) {
            console.debug(mouseEvent);
        errorDialog.hide();
        errorDialog.destroyRecursive();
        callbackFn(false);
                });

        //显示确定框
        errorDialog.show();
       }

你可能感兴趣的:(dojo)