Sha256: dbeec10a4f6d11ecde3047be441b282df3ef603fc2f5a71e843c53c7b5b1ae63
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
/** * Created by scout on 3/25/15. * "методы" по работе с модальными окнами. * */ (function($) { $.fn.modal_success = function(){ //console.log("modal_success>"); // close modal this.modal('hide'); // clear form input elements this.find('input[type="text"]').val(''); this.find('textarea').val(''); // clear error state this.clear_previous_errors(); }; $.fn.render_form_errors = function(errors){ var $form = this; this.clear_previous_errors(); var model = this.data('model'); // show error messages in input form-group help-block $.each(errors, function(field, messages){ var $input = $('input[name="' + model + '[' + field + ']"]'); if ($input.length == 0) { $input = $('textarea[name="' + model + '[' + field + ']"]'); } $input.closest('.form-group').addClass('has-error').find('.help-block').html( messages.join(' ') ); }); }; $.fn.clear_previous_errors = function(){ $('.form-group.has-error', this).each(function(){ //console.log($('.help-block', $(this))); $('.help-block', $(this)).html(''); $(this).removeClass('has-error'); }); $.rails.enableFormElements($(this)); }; $.fn.my_render_form_errors = function(errors) { var model = this.data('model'); $.each(errors, function(field, messages) { var $span = $('span#' + model + '_' + field); //console.log($span); $span.closest('.form-group').addClass('has-error'); $span.html( messages.join(' & ') ); }); }; }(jQuery));
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
c80_modal_forms-0.1.0 | app/assets/javascripts/modal_forms.js |
c80_feedback_form-0.1.0 | app/assets/javascripts/frontend/modal_forms.js |