I just saw this JQuery Metadata Plugin by John Resig, Yehuda Katz, Jarn Zaefferer, and Paul McLanahan, in my search for JQuery Form Validation, and that's an interesting idea!
I'm wondering what general best practices are for storing things like error/validation text, tooltip text, default value text, etc. I know you can place them into the title="My Tooltip Message"
attribute, but that would get very messy and wouldn't be DRY if a lot of my items had the same tooltips and errors so to speak.
So is there anything wrong with storing all of that in either hidden input fields or html metadata? Or is there a better way of just storing it all in an XML config file and getting them out via JQuery?
HTML5 supports custom attributes starting with "data-" ex: "data-origvalue" could store the original value of an input which could be used later to determine if the user changed it.
JQuery 1.4 now supports this natively using the .data() functions: http://api.jquery.com/data/
If you're not going to use JQuery, the official best practice recommendation is to use something like "data-LIBRARYNAME-ATTRNAME" ex: "data-jquery-origvalue" so no two libraries will conflict. I suggest you follow this and come up with some unique for the "LIBRARYNAME" part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With