Using hyphens in argument names

1.5k views Asked by At

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: am 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?

3

There are 3 answers

3
naugtur On BEST ANSWER

try using quotes 'data-icon' or doublequotes "data-icon"

It's being interpreted as a minus not a dash

0
Elliott On

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).

2
beardedd On

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)#