【问题标题】:Force JQuery Dialog Title to Multiple Lines强制 JQuery 对话框标题为多行
【发布时间】:2014-07-28 15:00:34
【问题描述】:

如何强制 jQuery 对话框的标题始终为两行?

看到这个:http://jsfiddle.net/VKcJ7/24/

我知道对话框标题包含在跨度中,所以我不确定这是否可能。我希望“某些项目”部分始终位于第一行,而“剩余数量...”部分始终位于第二行。

JS:

$(document).ready(function () {
    $('#dialog').dialog({
        autoOpen: false,
        modal: true,
        title: 'SOME ITEM \n Remaining Qty (Cts.): 0'
        //adding the newline character \n is ignored...
    });
});

CSS:

.ui-dialog .ui-dialog-title {
    white-space:normal;
}

【问题讨论】:

  • @RobertHarvey a
    只是作为标题文本的一部分添加
  • 我猜你必须破解 jQuery Dialog 源代码。

标签: javascript jquery css jquery-ui jquery-ui-dialog


【解决方案1】:

我最终使用了这个问题的答案(感谢@jazZRo): Using HTML in a Dialog's title in jQuery UI 1.10 扩展小部件。

然后我将我的标题设置如下:(工作示例:http://jsfiddle.net/VKcJ7/30/

JS:

$(document).ready(function () {
    $('#dialog').dialog({
        autoOpen: false,
        modal: true,
        title: 'SOME ITEM <br> Remaining Qty (Cts.): 0'
        //adding the newline character \n is ignored...
    });
});

【讨论】:

    【解决方案2】:

    官方认为你不能。

    hacky 的方法是把它塞进去:

    $("#dialog")
        .dialog({
          autoOpen: false
        })
        .closest(".ui-dialog")
          .find(".ui-dialog-title")
            .html("Dialog<br>Title");
    

    Live Example | With resizable: true

    但同样,相当老套。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    • 1970-01-01
    相关资源
    最近更新 更多