Custom Attributes for Buttons in jade
Hi I'm trying to code a webpage using node.js and jade. I'm trying to add a custom attribute to a button, like in HTML:
where someSpecialID is a value passed into the template by the node server. I've tried:
input(type = "button", specialID = someSpecialID, onclick = "doSomething(specialID);")
input(type = "button", onclick = "doSomething(specialID);") specialID = someSpecialID
but the custom attribute doesn't seem to take. I keep getting the error that specialID is not defined.
I'm still somewhat new to node.js and jade, so I'm sorry if this is a trivial question. I'd greatly appreciate any help on this.
If it's the former, you could use interpolation (between quotes, because I think Jade expects quotes, i.e.:
If it's the latter, something like this would render correctly:
input(type="button", specialID="someSpecialID", onclick="doSomething(specialID);")
You should consider using a
data-special-id attribute instead of
specialID (custom attributes are "normalized" in HTML5 with the data- prefix).