Class: Mack::JavaScript::Framework::JqueryAjax

Inherits:
Object
  • Object
show all
Defined in:
lib/mack-javascript/helpers/jquery_helper.rb

Class Method Summary collapse

Class Method Details

.remote_function(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/mack-javascript/helpers/jquery_helper.rb', line 9

def remote_function(options)
  javascript_options = options_for_ajax(options)
  function = "$.ajax(#{javascript_options})"

  function = "#{options[:before]}; #{function}" if options[:before]
  function = "#{function}; #{options[:after]}"  if options[:after]
  function = "if (#{options[:condition]}) { #{function}; }" if options[:condition]
  function = "if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }" if options[:confirm]
  return function
end