简体   繁体   English

如何在不破坏javascript确认的情况下在我的消息资源中添加撇号?

[英]how to put an apostrophe in my message resource without breaking the javascript confirm?

I'm using JSF2 (Primefaces 2.x, and GlassFish 3.1.x). 我正在使用JSF2(Primefaces 2.x和GlassFish 3.1.x)。

I have a 'delete' button with a javascript confirmation. 我有一个带有JavaScript确认的“删除”按钮。

<p:commandButton ajax="false" value="#{msg.common_delete}"
  action="#{profileHandler.doDelete}"
  onclick="return confirm('#{msg.profile_confirmDeleteMessage}')"
  immediate="true"
/>

The problem is the message in the resource bundle has an apostrophe. 问题是资源束中的消息带有撇号。 Like "Are you sure you want to delete the user's profile?" 就像“您确定要删除用户的个人资料吗?”

The apostrophe is breaking the javascript so the confirmation message never appears, the button just does the delete. 撇号破坏了javascript,因此确认消息永不出现,该按钮仅执行删除操作。

I tried changing the text in the message bundle to ' and ' but neither worked; 我尝试将消息束中的文本更改为“和”,但均无济于事。 I just see the "'" in the message. 我只看到消息中的“'”。

Any help is greatly appreciated! 任何帮助是极大的赞赏!

Rob

您可以尝试在邮件属性文件中的'字符前添加\\'。

Does JSF2 allow single quoted attributes? JSF2是否允许单引号属性? If so, you can try switching out the outer qutoes to be single quotes and the inner ones to be double quotes. 如果是这样,您可以尝试将外部quto替换为单引号,将内部quto替换为双引号。 That way js shouldn't get confused. 这样一来,js就不会感到困惑。

onclick='return confirm("#{msg.profile_confirmDeleteMessage}")'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM