[英]Escape closing Tag in embedded JavaScript on a JSF page
I've got a following JS function that formats my results used in select2 我有一个以下JS函数,用于格式化我在select2中使用的结果
function format(item) {
if (item.text.match(/\[\d{4}\]/g)) {
return "<b>" + item.text + "</b>";
}
return item.text;
}
If I leave it as it is I am getting following error in the JS console: 如果我将其保留原样,则会在JS控制台中收到以下错误消息:
SyntaxError: unterminated string literal
return "<b>" + item.text + "
If I escape the slash like so <\\\\/b>
then javax.faces.view.facelets.FaceletException complaints about not well-formatted code. 如果我像这样<\\\\/b>
逃脱斜线,那么javax.faces.view.facelets.FaceletException会抱怨代码格式不正确。
Any suggestions? 有什么建议么?
我通过将格式函数导出到外部JavaScript文件并使用以下巧妙技巧来处理它:
return "<b>" + item.text + "<" + "/b>";
Ohhh, i see then it is jsf special charachter parsing issue. 哦,我看到的是jsf特殊字符解析问题。 '<'
is "<"
'<'
是"<"
and '>'
is ">"
并且'>'
是">"
. 。
Replace these characters like: 替换这些字符,例如:
return "<b>" + item.text + "</b>";
This will work for you. 这将为您工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.