Skip to content

Instantly share code, notes, and snippets.

@Brachamul
Created October 5, 2017 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Brachamul/3e53d65b9a21f8a9210e718ef648e777 to your computer and use it in GitHub Desktop.
Save Brachamul/3e53d65b9a21f8a9210e718ef648e777 to your computer and use it in GitHub Desktop.
// bootstrapify the default django-allauth forms
$('form p').replaceWith(function() { return '<div>' + this.innerHTML + '</div>'; });
$('form input').each(function(index){
$input = $(this)
var t = $input.attr('type')
if (t == 'text' || t == 'email' || t == 'password' || typeof t == 'undefined' ) {
$input.addClass('form-control')
$input.closest('div').addClass('form-group')
}
if (t == 'radio' || t == 'checkbox' ) {
var $label = $input.siblings('label')
$label.text(' ' + $label.text().slice(0, -1))
$input.addClass('form-check-input')
$label.addClass('form-check-label')
$input.closest('div').addClass('form-check')
$input.prependTo($label)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment