Last active
August 29, 2015 14:05
-
-
Save craigmdennis/abad157062b4c0e74817 to your computer and use it in GitHub Desktop.
Allow jQuery Validate to mark Chosen select box as valid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allow jQuery Validate to run validation on jQuery Chosen | |
# select boxes by changing the ignore selector from `:hidden` | |
$.validator.setDefaults | |
ignore: '.no-validate' | |
# jQuery Validate doesn't mark fields as valid on hidden elements | |
# So when using Chosen we need to show the original input, | |
# give it focus and then hide it again | |
$('.js-chosen-select').on 'change', -> | |
$(this).show().css | |
'position' : 'absolute' | |
'left': '-9999px' | |
'opacity' : '0' | |
.focus() | |
.attr('style','') | |
.hide() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment