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

Add class to the .control-group div for twitter bootstrap #11

Closed
pmeissner opened this issue Jan 20, 2013 · 10 comments
Closed

Add class to the .control-group div for twitter bootstrap #11

pmeissner opened this issue Jan 20, 2013 · 10 comments

Comments

@pmeissner
Copy link

I'll just throw this out there. It would be nice if the error class could be added to the .control-group containing div to use twitter bootstraps classes. Or an example of how to implement it.

.control-group.error {
  @include formFieldState($errorText, $errorText, $errorBackground);
}
@guillaumepotier
Copy link
Owner

Hi,

Parsley is currently totally agnostic of twitter bootstrap or other templating framework. All error-related stuff is totally overridable on config. For example, your could here https://github.com/guillaumepotier/Parsley.js/blob/master/parsley.js#L885 use a custom classHandler( element ) function that will return the right DOM elem on which you want to put the error class.

I'll add code explanations on how to do that in the documentation

@pmeissner
Copy link
Author

Awesome. I've been looking for a nice validator that is more modern than some of the older jquery versions out there.

@guillaumepotier
Copy link
Owner

I reopen this issue until I've put this in doc. Helps me not to forgot to do it ;)

@pmeissner
Copy link
Author

If you want to play around with it http://jsfiddle.net/pmeissner/WdMu8/

@guillaumepotier
Copy link
Owner

Ok. I made a first step in doc.

Will follow up in the week, and maybe think about "classical" bootstrap integrations (tooltips, .control-group..)

@JensRantil
Copy link
Contributor

Ok. I made a first step in doc.

@guillaumepotier Just curious, what changes did you make?

@guillaumepotier
Copy link
Owner

Not much though: b58c344#diff-3

Should continue and add typical customization uses-cases, with default twitter tooltip / popover for example + tests in test suite ;)

@KennyEliasson
Copy link

I just added the following to make it work with nice with bootstrap.

listeners: {
onFieldError: function (elem, constraints, ParsleyField) {
$(elem).closest('.control-group').removeClass('success').addClass('error');
},
onFieldSuccess: function (elem, constraints, ParsleyField) {
$(elem).closest('.control-group').removeClass('error').addClass('success');
}
},
errors: {
errorsWrapper: '',
errorElem: ''
},

@twickstrom
Copy link

Kenny I am doing something, however my code looks like:

listeners: {
successClass: 'success',
errorClass: 'error',
errors: {
classHandler: function (el) {
return jQuery(el).closest('.control-group');
},
errorsWrapper: '',
errorElem: ''
}
}

@KennyEliasson
Copy link

Well that was alot cleaner :)

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

No branches or pull requests

5 participants