Module: Jquelpers::CalculatorHelper

Defined in:
lib/jquelpers/calculator_helper.rb

Instance Method Summary collapse

Instance Method Details

#calculator_tag(object, method, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/jquelpers/calculator_helper.rb', line 4

def calculator_tag(object, method, options = {})
  jquery = Jquelpers.default[:calculator][:jquery] << (options.delete(:jquery).to_s ||= "")
  options = (Jquelpers.default[:calculator][:html] ||= {}).merge(options)

  Jquelpers.need_stylesheet :UI, :calculator
  Jquelpers.need_javascript :jquery, :calculator, :calculator_I18n

  jquelpers_include_specifics if options.delete(:include) === :force

  concat text_field(object.class.name.downcase, method, options)
  javascript_tag "$(document).ready(function() {$(#{object.class.name.downcase}_#{method.to_s}).calculator({#{jquery}}); });"
end