页面消息

两种页面级消息

表单消息

使用:$.setValSum(obj, msgs), $.clearValSum(obj)

向指定 form 中的 ValidationSummary 添加信息。

示例:



“显示消息”、“清除消息”按钮脚本:

$("#setValSum").on("click", function (e) {
    e.preventDefault();
    $.setValSum($("#form-movie-c"), ["msg1", "msg2"]);
});

$("#clearValSum").on("click", function (e) {
    e.preventDefault();
    $.clearValSum($("#form-movie-c"));
});

页面消息

使用:$.notify()

使用 Bootstrap Notify。详见: https://github.com/mouse0270/bootstrap-growl

示例:

显示消息
<div class="btn-group btn-group-toggle mr-4" data-toggle="buttons">
    <label class="btn btn-outline-success">
        <input type="radio" name="type" id="option1" value="success" autocomplete="off"> 成功
    </label>
    <label class="btn btn-outline-info">
        <input type="radio" name="type" id="option2" value="info" autocomplete="off"> 消息
    </label>
    <label class="btn btn-outline-warning active">
        <input type="radio" name="type" id="option3" value="warning" autocomplete="off" checked> 警告
    </label>
    <label class="btn btn-outline-danger">
        <input type="radio" name="type" id="option4" value="danger" autocomplete="off"> 危险
    </label>
</div>
<a id="notify" class="btn btn-primary" href="#">
    显示消息
</a>
$("#notify").on("click", function (e) {
    e.preventDefault();
    $.notify('使用 $.notify 显示消息。', {
        type: $('input[name="type"]:checked').val()
    });
});

sg 默认使用 warning 样式
// 最简方式,使用 warning 样式显示消息。
$.notify('你的消息');

// 使用 success 样式显示。 
$.notify('你的消息', {
    type: "success"
});

$.notify 在弹出窗口中显示

$.notify 默认 z-index: 1031,bs 模态窗口默认 z-index: 1050。此时 $.notify 显示的信息将被模态窗口覆盖。sg 将 $.notify z-index 默认值设置为 1100

示例:

$.notify 信息将显示在模态窗口之上。

打开窗口