Sha256: 2cdb85b572ed18aefc000a78551d30a38163e0e85e3c468448b5ce825d453170

Contents?: true

Size: 788 Bytes

Versions: 9

Compression:

Stored size: 788 Bytes

Contents

module OpenStax
  module Connect
    module ApplicationHelper

      def unless_errors(options={}, &block)
        options[:errors] ||= @handler_result.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

9 entries across 9 versions & 1 rubygems

Version Path
openstax_connect-0.1.0 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.10 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.9 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.8 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.7 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.6 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.5 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.4 app/helpers/openstax/connect/application_helper.rb
openstax_connect-0.0.3 app/helpers/openstax/connect/application_helper.rb