Using hyphens in argument names
I am working with CFWheels and jquery mobile and am trying to pass some jquerymobile settings into a linkto call (mainly the data-icon attribute. I never new this before, but it appears to be that ColdFusion doesn't allow hyphens in argument names. My call is as follows:
<cfset contentFor(actioncontent=linkTo(text='Login', route='login', data-icon='check')) />
CFBuilder and Railo throw an error on the hyphen. The Railo error is:
invalid assignment left-hand side (railo.transformer.bytecode.op.OpDouble)
So my questions is: a开发者_如何学Pythonm I correct in saying that hyphens are not allowed in argument names? Also if they are not allowed, is there a way to get the hyphen through or do I just have to create the anchor tag?
try using quotes 'data-icon'
or doublequotes "data-icon"
It's being interpreted as a minus not a dash
You can get this to work on Railo and Adobe's CF by creating a struct first and sending it in the argument collection. Otherwise, it will only work on Railo.
Example:
<cfscript>
args = {controller="form",
'data-role'="button",
'data-theme'="c",
text="I Accept"};
</cfscript>
#linkTo(argumentCollection=args)#
My quick hack is this:
#replace(linkTo(text="I accept", route="dashboard"),"<a ","<a data-role='button' ","ALL")#
(emphasis on the work hack - not ideal, but much easier than passing in the argumentCollection).
精彩评论