样式jquery alertify-plugin

时间:2013-12-10 19:53:15

标签: jquery css plugins alertify

要更改jquery alertify插件的样式,我执行了以下操作, 这是头部,所有文件都加载(我希望如此)正确的顺序:

<head>
    <meta charset="UTF-8" />

    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script type="text/javascript" src="javascript/jquery-2.0.3.min.js"></script>

    <script type="text/javascript" src="alert/alertify.min.js"></script>
    <script type="text/javascript" src="javascript/onsubmit.js"></script>

    <link rel="stylesheet" href="alert/alertify.default.css" />
    <link rel="stylesheet" href="alert/alertify.core.css" />
    <link rel="stylesheet" href="alert/alertify.bootstrap.css" />
    <link rel="stylesheet" href="style/style.css" />

</head>

这是onsubmit.js:

$(document).ready(function(){
  $("form").submit(function(){
    var dump = $("#dump").val();
    if(dump) { 
        $.ajax({
            url: 'check.php',
            data: {data: JSON.stringify(dump)},
            type: 'POST',
            dataType: "json",
            success: function (data) {
                if(data.result == 1) {
                    alertify.alert( data.error, function() {}, 'popup1' ); // the first popup styled
                    return false;
                } 
                if(data.result == 0) {
                    alertify.alert( data.error, function() {}, 'popup1' ); // the second popup styled
                    return false;
                }           
            }
        });
    } else { 
        alertify.alert("message");
        return false;
    }

  });
});

的style.css:

.alertify.popup1 {
    background: red;
}
.alertify.popup2 {
    background: blue;
}

但接收数据的警报框仍然显示正常且未修改。 我只是按照他的步骤: How to insert an image into an alertify.js alert with JavaScript?,我的style.css包含在alertify.css之后,所以有人可以帮我解决我的问题吗?问候

1 个答案:

答案 0 :(得分:0)

删除双jQuery include。

可能您没有设置第3个参数,用于自定义UI:

  

[可选]要附加到对话框的类

代码:

$(document).ready(function() {
    $('#clicky').on('click', function(event) {
        event.preventDefault();
        alertify.confirm('Are you sure you want to delete this section?', function(e) {
            if (e) {
            }
        },'popup2');
    });
});

演示:http://jsfiddle.net/kBnPy/