bootstrap-select.js and validationEngine fix
If you're trying to use:
bootstrap-select.js https://github.com/silviomoreto/bootstrap-select
and
jquery.validationEngine.js https://github.com/posabsolute/jQuery-Validation-Engine
You will most likely run into an issue where the selects will never seem to validate.
There's an easy fix, that took me a bit of fiddling to figure out.
When bootstrap-select creates a cloned element, it uses an addClass that copies the validate[.*] class into the new div element, and validationEngine tries to validate that.
This can be remedied by modifying the setStyle function to strip that part of the class attribute out (at line 272 of bootstrap-select.js):
this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|validate\[.*\]/gi, ''));
Note the change is simply: |validate\[.*\] in the regular expression.
This keeps the new DIV element from being "validated" by the validationEngine script.
After adding this, validationEngine works for me with bootstrap-select. Huzzah!
I have a pull request here: https://github.com/lawrencealan/bootstrap-select/commit/66a73ceb3a1c155bdeff127fb2330e51f73e1abf
Written by Larry Williamson
Related protips
Have a fresh tip? Share with Coderwall community!
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside