Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 244
Dave Long Avatar asked Feb 25 '23 00:02

Dave Long


2 Answers

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

It's being interpreted as a minus not a dash

like image 139
naugtur Avatar answered Mar 10 '23 18:03

naugtur


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)#
like image 39
beardedd Avatar answered Mar 10 '23 16:03

beardedd