jQuery UI Alert Dialog as a replacement for alert()

前端 未结 9 591
独厮守ぢ
独厮守ぢ 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:39

    Using some of the info in here I ended up creating my own function to use.

    Could be used as...

    custom_alert();
    custom_alert( 'Display Message' );
    custom_alert( 'Display Message', 'Set Title' );
    

    jQuery UI Alert Replacement

    function custom_alert( message, title ) {
        if ( !title )
            title = 'Alert';
    
        if ( !message )
            message = 'No Message to Display.';
    
        $('
    ').html( message ).dialog({ title: title, resizable: false, modal: true, buttons: { 'Ok': function() { $( this ).dialog( 'close' ); } } }); }

提交回复
热议问题