Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

strange behaviour between showErrors & clearErrors on non-native select #251

Closed
maximelebreton opened this issue Dec 15, 2015 · 2 comments
Closed
Assignees

Comments

@maximelebreton
Copy link

Hi @1000hz, and thanks a lot for the work!

I use Bootstrap select, and have a little problem.
First, i have to made this little modification (because bootstrap-select hide the native select):

$.fn.validator.Constructor.INPUT_SELECTOR = ':input:not([type="submit"], button):enabled'

And it works.

But, when i have errors, there is no .has-error class on the parent .form-group and no .help-block messages.
I don't understand because the markup is in the right place:
image

And in the Validator.prototype.showErrors function, the variables $group, $block and errors are good.

So the problem seems to be in Validator.prototype.clearErrors function, who's called at the same time !?

If i comment the code:
image

it works...
image

Any idea?

Thanks!


EDIT 1:

i've made a JSBin, and it's working with one element.
http://jsbin.com/qorinewoyi/edit?html,output


EDIT 2:

Ok, i have reproduced the problem, it's when you have more than one element, it keep only the last one:
(and if I comment the clearErrors function, this behaviour disapear)
http://jsbin.com/javihugewa/edit?html,output

any idea of how to fix this?

@maximelebreton
Copy link
Author

okay, #112 fix that case.
thanks @r0ro for your pull request!
@1000hz can you merge it?

@1000hz
Copy link
Owner

1000hz commented Feb 25, 2016

It looks like the button bootstrap-select added triggers a focusout event which causes a revalidation and clears the error. I'll fix this in the next version so that the event handlers are scoped only to events from INPUT_SELECTOR elements.

@1000hz 1000hz self-assigned this Feb 25, 2016
@1000hz 1000hz closed this as completed in fa5955f Mar 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants