Sha256: 42cfd868acef6851ec6d74c94125adcddfb9b34418080082001c2e3d74667570

Contents?: true

Size: 773 Bytes

Versions: 2

Compression:

Stored size: 773 Bytes

Contents

module OpenStax
  module Connect
    module ApplicationHelper

      def unless_errors(options={}, &block)
        options[:errors] ||= @errors
        options[:errors_html_id] ||= OpenStax::Connect.configuration.default_errors_html_id
        options[:errors_partial] ||= OpenStax::Connect.configuration.default_errors_partial
        options[:trigger] ||= OpenStax::Connect.configuration.default_errors_added_trigger

        if options[:errors].any? || flash[:alert]
          "$('##{options[:errors_html_id]}').html('#{ j(render options[:errors_partial], errors: options[:errors]) }').trigger('#{options[:trigger]}');".html_safe
        else
          ("$('##{options[:errors_html_id]}').html('');" + capture(&block)).html_safe
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstax_connect-0.0.2 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.1 app/helpers/openstax/connect/application_helper.rb