regula icon indicating copy to clipboard operation
regula copied to clipboard

bind vs validate: element vs elementId

Open troyji opened this issue 13 years ago • 1 comments

regula.bind takes an option parameter of 'element', which is a DOM element to operate on. regula.validate takes an option parameter of 'elementId', a string id of an element to operate on. This is inconsistent.

Instead of changing to one or the other, I would propose that both functions should simply allow either parameter.

It could also be argued that both methods should accept an array of element id strings of elements ('elementIds') to operate on in addition to their already existing parameter that takes a list of DOM elements ('elements') to operate on.

troyji avatar Sep 02 '11 03:09 troyji

The reason I used elementId in validate() initially was to enforce the requirement that all elements that are validated, require id's. But since regula automatically adds id's to elements that don't have id's, I'd say this requirement isn't necessary anymore; your suggestions make sense and I'll put this on my list of things to do :).

vivin avatar Sep 02 '11 15:09 vivin