简体   繁体   English

Javascript多级嵌套引号

[英]Javascript Multi-level Nested Quotes

I'm doing some work w/ the JQWidgets grid which requires replacing the value in a column w/ an image. 我正在使用JQWidgets网格进行一些工作,这需要替换带有图像的列中的值。 To do this, I need to return a string to the cellsrenderer. 为此,我需要将字符串返回到cellrenderer。 In addition, clicking on the icon will perform a Javascript function call, passing several parameters. 另外,单击图标将执行Javascript函数调用,并传递几个参数。 One of the parameters is a string value, and I'm having difficulty setting up my return string. 参数之一是字符串值,我在设置返回字符串时遇到困难。

The Javascript function I'm calling takes 4 variables - three integers and a string. 我正在调用的Javascript函数需要4个变量-三个整数和一个字符串。 This is the code for the return: 这是返回的代码:

return "<span style='margin:4px; display:block;'><a href='javascript:;' onclick='unenroll(" + courseID + ", \"courseName\", " + progress + ", " + userID + ")' class='delete-icon' title='<cfoutput>#APPLICATION.LC.getValue("UnassignFrom")#</cfoutput> ' + courseName + '?'><cfoutput>#APPLICATION.LC.getValue("UnassignFrom")#</cfoutput> ' + courseName + '?</a></span>";

courseID, courseName, progress and userID are all Javascript variables; courseID,courseName,progress和userID都是Javascript变量; courseName is a string. courseName是一个字符串。

As you can see, I've tried escaping the quotes around the courseName w/ slashes, which doesn't work. 如您所见,我已经尝试用斜杠转义CourseName周围的引号,但这是行不通的。 Neither does encoding Unicode or HTML-entity versions of quotes. 也不对Unicode或HTML实体版本的引号进行编码。 I've even tried switching around all the quotes (ie. from single to double and double to single), but still nothing. 我什至尝试切换所有引号(即,从单引号到双引号和从双引号到单引号),但还是一无所有。

Edit - this is what I'm getting back from Firebug: syntax error unenroll(2333, "Exam Automation", 50, ) 编辑-这是我从Firebug中获得的信息:语法错误unenroll(2333,“ Exam Automation”,50,)

您只是错过了“ UnassignFrom”附近的一些转义引号,这是正确的版本:

return "<span style='margin:4px; display:block;'><a href='javascript:;' onclick='unenroll(" + courseID + ", \"courseName\", " + progress + ", " + userID + ")' class='delete-icon' title='<cfoutput>#APPLICATION.LC.getValue(\"UnassignFrom\")#</cfoutput> ' + courseName + '?'><cfoutput>#APPLICATION.LC.getValue(\"UnassignFrom\")#</cfoutput> ' + courseName + '?</a></span>"

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

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