jquery-ui - 在 jQuery UI 1.10 中的对话框标题中使用 HTML

标签 jquery-ui

http://jqueryui.com/upgrade-guide/1.10/#changed-title-option-from-html-to-text

jQuery UI 1.10 使对话框标题只能是文本(无 html),以防止脚本漏洞。我不允许用户输入来生成这个标题,所以我仍然想使用 HTML,主要是在标题左侧显示一个图标。

我将发布我对此问题的解决方案,因为我还没有看到其他人提出或回答这个问题。希望它能帮助其他人,或者其他人可能有更好的方法。

有关他们这样做的原因的更多信息:http://bugs.jqueryui.com/ticket/6016

最佳答案

这将覆盖设置 jQuery UI 对话框标题时使用的函数,允许它包含 HTML。

$.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
    _title: function(title) {
        if (!this.options.title ) {
            title.html(" ");
        } else {
            title.html(this.options.title);
        }
    }
}));

关于jquery-ui - 在 jQuery UI 1.10 中的对话框标题中使用 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14488774/

相关文章:

jquery-ui - 从 Angular 打开 jquery 对话框的最佳实践是什么?

javascript - jQuery UI - 以某种方式拖动会忽略溢出 :hidden

JQuery UI 范围 slider 值

jquery:如何更新可拖动克隆ID?

javascript - jquery draggable 在将 div 设置为 "position: static"后停止工作

javascript - 模式框在运行时更改标题和按钮名称

jquery - 自定义 Jquery UI 微调器

悬停时 jQuery UI 尺寸效果然后返回原始尺寸

jquery - 如何知道slideToggle()是向上还是向下移动?

javascript - jQuery UI 菜单获取/设置事件的 ui-menu-item