Class: JQueryOnRails::Helpers::JavaScriptElementProxy

Inherits:
JavaScriptProxy
  • Object
show all
Defined in:
lib/jquery_on_rails/helpers/jquery_helper.rb

Overview

Adapted from Rails 3 ActionView::Helpers::JavaScriptProxy

Instance Method Summary collapse

Constructor Details

#initialize(generator, id) ⇒ JavaScriptElementProxy

Returns a new instance of JavaScriptElementProxy.



356
357
358
359
# File 'lib/jquery_on_rails/helpers/jquery_helper.rb', line 356

def initialize(generator, id)
  @id = id
  super(generator, "jQuery(#{::ActiveSupport::JSON.encode('#'+id.to_s)})")
end

Instance Method Details

#[](attribute) ⇒ Object



361
362
363
364
365
366
# File 'lib/jquery_on_rails/helpers/jquery_helper.rb', line 361

def [](attribute)
  if Fixnum === attribute then array_access(attribute) else
   append_to_function_chain!(attribute)
 end
  self
end

#[]=(variable, value) ⇒ Object



368
369
370
# File 'lib/jquery_on_rails/helpers/jquery_helper.rb', line 368

def []=(variable, value)
  assign(variable, value)
end

#reload(options_for_replace = {}) ⇒ Object



380
381
382
# File 'lib/jquery_on_rails/helpers/jquery_helper.rb', line 380

def reload(options_for_replace = {})
  replace(options_for_replace.merge({ :partial => @id.to_s }))
end

#replace(*options_for_render) ⇒ Object



376
377
378
# File 'lib/jquery_on_rails/helpers/jquery_helper.rb', line 376

def replace(*options_for_render)
  call 'replaceWith', @generator.send(:render, *options_for_render)
end

#replace_html(*options_for_render) ⇒ Object



372
373
374
# File 'lib/jquery_on_rails/helpers/jquery_helper.rb', line 372

def replace_html(*options_for_render)
  call 'html', @generator.send(:render, *options_for_render)
end