Styled alert system for javascript

前端 未结 1 1746
囚心锁ツ
囚心锁ツ 2021-01-17 06:06

i am using smoke.js which allows to style the classic alert javascript windows.

All you have to do is place .smoke before the alert ie. smoke.conf

相关标签:
1条回答
  • 2021-01-17 06:41

    The builtin javascript alert/confirm functions are synchronous, this is not. You need to handle the result of the confirm using the javascript callback pattern. You pass a function to the smoke.confirm() function which called when you need to respond to an action.

    See the following code. The if around the smoke.confirm() has been removed and the handling code is wrapped in the function passed to the smoke.confirm() function.

    $(".upb_del_bookmark").click( function() {
        smoke.confirm(delete_message, function(e) {
            if(e){
                var post_id = $(this).attr('rel');
                var data = {
                    action: 'del_bookmark',
                    del_post_id: post_id
                };
                $.post(upb_vars.ajaxurl, data, function(response) {
                    $('.bookmark-'+post_id).fadeOut();
                    $('.upb_bookmark_control_'+post_id).toggle();
                });
            }
        });
    }
    

    I highly recommend reading a little about the callback pattern in javascript. It's very common and understanding it will help you use this plugin and many others.

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