jQuery UI Alert Dialog as a replacement for alert()

前端 未结 9 544
独厮守ぢ
独厮守ぢ 2020-12-13 18:51

I\'m using alert() to output my validation errors back to the user as my design does not make provision for anything else, but I would rather use jQuery UI dial

相关标签:
9条回答
  • 2020-12-13 19:45

    There is an issue that if you close the dialog it will execute the onCloseCallback function. This is a better design.

    function jAlert2(outputMsg, titleMsg, onCloseCallback) {
        if (!titleMsg)
            titleMsg = 'Alert';
    
        if (!outputMsg)
            outputMsg = 'No Message to Display.';
    
        $("<div></div>").html(outputMsg).dialog({
            title: titleMsg,
            resizable: false,
            modal: true,
            buttons: {
                "OK": onCloseCallback,
                "Cancel": function() {
              $( this ).dialog( "destroy" );
                }
    
            },
        });
    
    0 讨论(0)
  • 2020-12-13 19:46

    Just throw an empty, hidden div onto your html page and give it an ID. Then you can use that for your jQuery UI dialog. You can populate the text just like you normally would with any jquery call.

    0 讨论(0)
  • 2020-12-13 19:54

    DAlert jQuery UI Plugin Check this out, This may help you

    0 讨论(0)
提交回复
热议问题