iamthechad
3/17/2014 - 8:49 PM

Twitter Bootstrap 3 and Parsely 2

Twitter Bootstrap 3 and Parsely 2

/*
 The most recent 2.0 Release Candidate of Parsely has changed how overriding
 options works. Here's what worked for me with Twitter Bootstrap 3.1 and
 Parsely 2.0.0-RC4
*/
$(document).ready(function () {
  $('#entryForm').parsley({
    successClass: 'has-success',
    errorClass: 'has-error',
    // classHandler, errorsWrapper, and errorTemplate are now at the
    // top-level and not part of the errors: {} object
    classHandler: function(ParsleyField) {
      // classHandler now takes a ParselyField argument
      // that has a $element property
      return $(ParsleyField.$element).closest('.form-group');
    },
    errorsWrapper: '<span class=\"help-inline\"></span>',
    // Renamed from errorsElem
    errorTemplate: '<span></span>'
    });
}