HTML 5 data attributes

221 views
Skip to first unread message

Per Djurner

unread,
Jan 13, 2012, 4:55:40 PM1/13/12
to cfwh...@googlegroups.com
You can't pass in HTML 5 data attributes to a Wheels function the normal way.
For example, #linkTo(action="x", data-role="button",
data-dom-cache=true)#, fails because of the hyphens in the argument
names.

So, what do you think is the best way to add support for this in Wheels?

1) Pass in underscores which Wheels translates to hyphens.
#linkTo(action="x", data_role="button", data_dom_cache=true)#

2) New "data" argument that accepts a list (or struct/query as well probably)
#linkTo(action="x", data="role=button, dom-cache=true")#

/ Per

Simon Allard

unread,
Jan 13, 2012, 5:02:39 PM1/13/12
to cfwh...@googlegroups.com

I prefer the second option.

A+

Simon

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.

Donald Humphreys

unread,
Jan 13, 2012, 5:06:04 PM1/13/12
to cfwh...@googlegroups.com
You could easily support a variety of formats, depending on what
everyone thinks is best. I prefer the underscore option since it keeps
the same number of characters and you don't have to interpolate
strings into the "data" arguments. Also, you can do
#linkTo("data-role"="button")# the last time I tried in CF9. I have no
idea if it works in other CF servers.

Per Djurner

unread,
Jan 13, 2012, 5:16:49 PM1/13/12
to cfwh...@googlegroups.com
"data-role"="button" doesn't work in CF8.
Not sure about Railo but I think it works there.

Troy Murray

unread,
Jan 13, 2012, 6:05:08 PM1/13/12
to cfwh...@googlegroups.com
I was just thinking about something similar with HTML5 and Wheels.  Some of the new input types like "input type=tel" and "input type=email", will these work?



/ Per

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.




--
Troy Murray

Mike Craig

unread,
Jan 13, 2012, 7:51:28 PM1/13/12
to cfwh...@googlegroups.com
Another possible alternative?  

#linkTo(action="x", html5={"data-role"="button", "data-dom-cache"="true"})# 

At least, creating the struct this way works which means you could create the struct however you want elsewhere and pass it to the html5 attribute.

Just a thought.

Mike Craig

unread,
Jan 13, 2012, 7:52:19 PM1/13/12
to cfwh...@googlegroups.com
though the syntax would not work in 8, you can at least create a struct in 8 with hyphenate names.

Derek

unread,
Jan 13, 2012, 10:24:46 PM1/13/12
to cfwh...@googlegroups.com
I hate underscores, but i don't like option 2 even more. So unless there is a more elegant solution, I will go for #1.
I do like mcraig's solution. everyone just needs to upgrade to CF9!! :p or maybe we can have both options?

Per Djurner

unread,
Jan 14, 2012, 8:12:03 AM1/14/12
to cfwh...@googlegroups.com
@Troy:

The following is already supported in Wheels (although not yet
released I think):
textFieldTag(name="phone", type="tel")

/ Per

> --
> You received this message because you are subscribed to the Google Groups
> "ColdFusion on Wheels" group.

> To view this discussion on the web visit
> https://groups.google.com/d/msg/cfwheels/-/OdXLTg7COiAJ.

jmail

unread,
Jan 14, 2012, 9:16:41 AM1/14/12
to ColdFusion on Wheels
maybe we can do camel case?

#linkTo(action="x", dataRole="button", dataDomCache=true)#

if not then first option is much much better. Now everything in wheels
working same way - passing by named argument not by any struct or
something else. This will be compatible with html 4.01 attributes.

jmail
> >http://groups.google.com/group/cfwheels?hl=en.- Ukryj cytowany tekst -
>
> - Pokaż cytowany tekst -

Mohamad El-Husseini

unread,
Jan 14, 2012, 9:23:09 AM1/14/12
to cfwh...@googlegroups.com
I think I'm a fan of option two. Option one works well when using a single data attribute. But I feel a cleaner implementation would be passing a struct, and thus grouping any custom data attributions in the same argument.

Per Djurner

unread,
Jan 14, 2012, 11:29:07 AM1/14/12
to cfwh...@googlegroups.com
There's probably no perfect solution for this but here's one way to
add some kind of support for this at least:
https://github.com/perdjurner/cfwheels/commit/506f7b50ed989d5ccec56bb96cbd68ad875f07f2

With that in place you can call #textFieldTag(name="x",
dataDomCache=true)# and have dataDomCache converted to data-dom-cache
as the attribute name.

Also, remember that you can always pass in an argument with hyphens like this:
<cfset args["data-dom-cache"] = true>
#linkTo(action="x", argumentCollection=args)#

In other words my solution is just intended to make coding a little
more elegant :)

(the core team will of course have to decide if this is something that
should go in core)

/ Per

> --
> You received this message because you are subscribed to the Google Groups
> "ColdFusion on Wheels" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/cfwheels/-/ydqdN5agM7MJ.

George

unread,
Jun 24, 2012, 9:24:14 PM6/24/12
to cfwh...@googlegroups.com
Is there a planned permanent solution for this. 

I just started using the Cold Route plug in and that uses a bunch of other data arguments that I can not pass into my code!

George

unread,
Jun 24, 2012, 9:31:54 PM6/24/12
to cfwh...@googlegroups.com
I meant to say cold route has me install rails.js which uses a lot of these.

Chris Peters

unread,
Jun 25, 2012, 9:48:21 AM6/25/12
to cfwh...@googlegroups.com
Wouldn't some versions of ColdFusion store the argument name in your first example as DATADOMCACHE, thus making it impossible to know where to put the hypens in the attribute?

tpet...@gmail.com

unread,
Jun 25, 2012, 9:57:36 AM6/25/12
to cfwh...@googlegroups.com
yes, ACF translates all structure keys to uppercase _unless_ you use bracket notation.

> For more options, visit this group at
> http://groups.google.com/group/cfwheels?hl=en.

--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+unsubscribe@googlegroups.com.

George

unread,
Jun 25, 2012, 12:21:13 PM6/25/12
to cfwh...@googlegroups.com
Working / Not-working? 

This behavior seems to work out of the Box in wheels on linkTo tags

#linkTo(dataTab="bob")# results in <a data-tab="bob">

it just does not work in the wheels form tags, it converts it all to lower case. 

So . . . why one and not the other?

rjasonc

unread,
May 23, 2013, 4:37:11 PM5/23/13
to cfwh...@googlegroups.com
I tried the below in the linkTo tag and it didn't work for me. (CF 9 and cfwheels v1.1.8). It just changed it all to lower case.  Can anybody update the current status of this and any other possible work-arounds?

Jason

George

unread,
May 23, 2013, 10:22:43 PM5/23/13
to cfwh...@googlegroups.com
If I said I got it working I might have lied. Honestly these days I still use and love wheels but have started to back away from the view helpers. Writing and working with so much javascript, jquery, angular and what not It just started to make since to really see my html and the DOM structure and not hide it behind so much script. At the end of the day it does not take that much time to write stuff out.

So instead of using linkTo(), I use the Wheels URLFor() method <a href="urlFor()"></a>, that way I get what I need out of wheels and can do the rest myself.

Chris G

unread,
Feb 26, 2014, 12:55:26 PM2/26/14
to cfwh...@googlegroups.com
I'm bumping into this now and am using 1.2 RC1, but so far none of the solutions described within have worked for me. 

tomavey

unread,
Mar 1, 2014, 11:21:30 AM3/1/14
to cfwh...@googlegroups.com
For what is worth, here's what I do.  I use the underscore method and then put this method in my controller.cfc.

<cffunction name="linkTo">
<cfset var loc=structNew()>
<cfset var i="">
<cfloop list="#structKeylist(arguments)#" index="i">
<cfset loc[replace(i,"_","-","all")] = arguments[i]>
</cfloop>
<cfreturn super.linkTo(argumentCollection=loc)>
</cffunction>

Chris Geirman

unread,
Mar 1, 2014, 1:51:55 PM3/1/14
to ColdFusion on Wheels
Thanks! That's a good solution, and would make a simple yet useful plugin too. 


--
You received this message because you are subscribed to a topic in the Google Groups "ColdFusion on Wheels" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cfwheels/uTAQAVNa6Hk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cfwheels+u...@googlegroups.com.

To post to this group, send email to cfwh...@googlegroups.com.



--

FrogQuest | Photo Scavenger Hunts 
... adventurous, costume-clad teams scour the city, making spectacles of themselves and others as they frantically compete to capture daring, interactive photo quests on their smartphones. High score wins! (www.frogquest.com)
Reply all
Reply to author
Forward
0 new messages