preventDefault = (event) -> event.preventDefault() srp.session = new srp.Session() srp.signedUp = -> srp.login() srp.loggedIn = -> window.location = '/' #// TODO: not sure this is what we want. srp.updated = -> window.location = '/' srp.error = (message) -> if $.isPlainObject(message) && message.errors display_errors(message.errors) else alert(message) display_errors = (errors) -> clear_errors(); for field, error of errors if field == 'base' display_base_error(error); else display_field_error(field, error); clear_errors = -> $('#messages').empty(); display_field_error = (field, error) -> element = $('form input[name$="['+field+']"]') return unless element element.trigger('element:validate:fail.ClientSideValidations', error).data('valid', false) display_base_error = (message) -> messages = $('#messages') messages.append "