Class: Campo::Plugins::JQueryValidation::Klass
- Defined in:
- lib/campo/plugins/jqueryvalidation.rb
Overview
instance methods
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Klass
constructor
A new instance of Klass.
Methods inherited from Plugin
Methods included from Pluggable
#after_output, #before_output, #extras, #on_plugin, #plugged_in
Constructor Details
#initialize(opts = {}) ⇒ Klass
Returns a new instance of Klass.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/campo/plugins/jqueryvalidation.rb', line 132 def initialize( opts={} ) before_output do |fields,| #find the form name(s) @jqv_form_names = fields.find_all{|x| x.kind_of? Campo::Form }.map{|x| x.attributes[:name]} @jqv_form_names << opts[:form] unless opts[:form].nil? || opts[:form].empty? end after_output do |output,| # concat to the current output out = jquery_script_declaration + output Rules.reset out end on_plugin do # adds `validate` to Convenience, it's an easy way to get it where it needs to be Campo::Base.send(:include, Campo::Plugins::JQueryValidation::InstanceMethods::Convenience) # only for the outputter Campo::Outputter.send(:include, Campo::Plugins::JQueryValidation::InstanceMethods::Outputter) end end |