weavejester / hiccup

Fast library for rendering HTML in Clojure
http://weavejester.github.io/hiccup
Eclipse Public License 1.0
2.68k stars 174 forks source link

Fixed label id generation code #84

Closed cyrax6 closed 11 years ago

cyrax6 commented 11 years ago

label seems to generate wrong html code. The atom we should use is :id and not :for.

weavejester commented 11 years ago

Why should a label use :id?

cyrax6 commented 11 years ago

It currently expands to for="some id". Besides for looking up labels to modify them in say JavaScript we need ids. There appears no format by which ids can be generated for labels. On 9 Aug 2013 05:27, "James Reeves" notifications@github.com wrote:

Why should a label use :id?

— Reply to this email directly or view it on GitHubhttps://github.com/weavejester/hiccup/pull/84#issuecomment-22390990 .

weavejester commented 11 years ago

You can add the ID explicitly as an attribute:

(label {:id "label-email"} :email "Email")
(text-field :email)

The reason the for attribute is the default is that you almost always want a label with for (after all, that's the only thing that differs a label from plain text), but only occasionally do you want a label with id (when you want to refer to the label directly via Javascript or perhaps through CSS).

cyrax6 commented 11 years ago

Ash. I see. My current code uses :label directive. Apologies for assuming things On 9 Aug 2013 05:49, "James Reeves" notifications@github.com wrote:

You can add the ID explicitly as an attribute:

(label {:id "label-email"} :email "Email")(text-field :email)

The reason the for attribute is the default is that you almost always want a label with for (after all, that's the only thing that differs a label from plain text), but only occasionally do you want a label with id(when you want to refer to the label directly via Javascript or perhaps through CSS).

— Reply to this email directly or view it on GitHubhttps://github.com/weavejester/hiccup/pull/84#issuecomment-22391942 .