在jQuery UI 1.10中的对话框标题中使用HTML [英] Using HTML in a Dialog's title in jQuery UI 1.10
问题描述
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屋!