在 jQuery UI 1.10 的对话框标题中使用 HTML [英] Using HTML in a Dialog's title in jQuery UI 1.10

查看:17
本文介绍了在 jQuery UI 1.10 的对话框标题中使用 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

jQuery UI 1.10 made it so that the dialog title can only be text (no html) to prevent scripting vulnerabilities. I'm not allowing user input to generate this title, so I would still like to use HTML, mainly to display an icon to the left of the title.

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

I'm going to post my solution to this problem because I haven't seen anyone else ask or answer this yet. Hopefully it will help someone else, or someone else may have a better approach.

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

More info as to why they did it: http://bugs.jqueryui.com/ticket/6016

推荐答案

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

This will override the function used when setting jQuery UI dialog titles, allowing it to contain 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 1.10 的对话框标题中使用 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆