4

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?

Ken Redler
  • 23,863
  • 8
  • 57
  • 69
Dave Long
  • 9,569
  • 14
  • 59
  • 89

3 Answers3

6

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

It's being interpreted as a minus not a dash

naugtur
  • 16,827
  • 5
  • 70
  • 113
  • Yup, this will work for Railo. Also, this can look JSON-like `"data-icon" : "check"`. – Sergey Galashyn Feb 21 '11 at 20:53
  • I am on Railo and will be hosting the application on Railo, but I was wondering if this will also work on ACF? I don't have an ACF server at my disposal to test on right now. – Dave Long Feb 21 '11 at 20:59
  • Thanks sergii. I enjoy knowing the the open source versions of CF have, in some ways, topped what Adobe has done. – Dave Long Feb 22 '11 at 15:40
2

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)#
beardedd
  • 371
  • 2
  • 6
  • 14
  • That would work, but is more code than @naugtur and has the same functionality across CF servers. – Dave Long Apr 01 '11 at 16:05
  • 1
    That's the point - @naugtur's method will only work on railo (possible openbd). It won't work on Adobe's CF server. My method works across both servers. It is more code, but if you need it to run on CF9, etc you don't really have a choice that I can see – beardedd Apr 01 '11 at 17:46
0

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

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291