Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetForm not working #1627

Closed
LinkCaau opened this issue Oct 29, 2015 · 7 comments
Closed

resetForm not working #1627

LinkCaau opened this issue Oct 29, 2015 · 7 comments
Labels

Comments

@LinkCaau
Copy link

in chrome v46,int resetForm() function unhighlight is no work,not remove errorClass.
I tracked on line 468 the elements variable is an object,this should be the Array of it.
http://jsfiddle.net/1t5nzoq2/

@staabm
Copy link
Member

staabm commented Oct 29, 2015

Thanks for reporting.

Just to make sure we are talking about the same problem:

-> expected: the form should render as on the initial page load
-> actual: form control still has red borders and label still are rendered in red color
Can you confirm that?

I get the same problem in FF43. Are you willing to provide a failling unit test?

@staabm
Copy link
Member

staabm commented Oct 29, 2015

Update: I just found a typo in your Fiddle which seems to be the culprit.

fixed version at http://jsfiddle.net/1t5nzoq2/

this

    unhighlight: function (element, errorClass) {
        $(element).closest('.control-group').removeClass(errorClass).removeClass('has-success');
    },

should be

    unhighlight: function (element, errorClass) {
        $(element).closest('.form-group').removeClass(errorClass).removeClass('has-success');
    },

right?

@Arkni
Copy link
Member

Arkni commented Oct 29, 2015

fixed version at http://jsfiddle.net/1t5nzoq2/

should be this instead: http://jsfiddle.net/1t5nzoq2/1/

@staabm staabm added the Invalid label Oct 29, 2015
@staabm staabm closed this as completed Oct 29, 2015
@staabm
Copy link
Member

staabm commented Oct 29, 2015

whatever ;-)

@LinkCaau
Copy link
Author

@staabm I initially found the problem appeared in the model of the form, and then found that the form of the page is the case, I think that both sides are the same, so ...
Please see my latest code,http://jsfiddle.net/1t5nzoq2/3/

  • open modal
  • click save button
  • close modal
  • open modal again

form control still has red borders and label still are rendered in red color.

@dkrahn
Copy link

dkrahn commented Oct 30, 2015

@chaodongyue it is just a missconfiguration.
The modal event you are using only executes after the modal components are already hidden.
So for your validation to work, you have two alternatives:

  • Instead of using the modal event "hidden.bs.modal", use "hide.bs.modal";
  • Or overwrite the ignore property with an empty string to the validation configuration, see the code http://jsfiddle.net/1t5nzoq2/5/;

@staabm I don't know if this would be a bug or not, but shouldn't the validation message also be kept, since the ignore property is filtering the input that is hidden?

@LinkCaau
Copy link
Author

@dkrahn Thank you very much, I finally know what happened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants