Parsley.js: never write a single JavaScript line to validate your forms 14 years ago
With Rails I did come up with a similar solution to Parley.js. Just add a helper that renders the needed data-attributes and you're done.
Your solution sounds nice for single page apps.