Sha256: 128bbd40a45d7ae7176158d31c2b7e03b2966588f3a3413979c3807ddd3d4965

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

<!-- Provides either an ajax or non-ajax button to invoke a "remote method" or "web method" declared in the controller.
Web Methods provide support for the RPC model of client-server interaction, in contrast to the REST model. The
preference in Rails is to use REST as much as possible, but we are pragmatists, and sometimes you just to need a remote
procedure call.

The URL that the call is POSTed to is the `object_url` of `this`, plus the method name

`<remote-method-button>` supports all of the standard ajax attributes (see the main taglib documention for Rapid
Forms). If any ajax attributes are given, the button becomes an ajax button, if not, Rails' `button_to` is used, which behaves similarly to a standard link.

### Attributes

 - method: the name of the web-method to call

 - label: the label on the button

 -->
<def tag="remote-method-button" attrs="method, update, label, confirm, url"><%=
  ajax_attributes, html_attributes = attributes.partition_hash(HoboRapidHelper::AJAX_ATTRS)

  url ||= object_url(this, method.to_s.gsub('-', '_'), :method => :post)
  raise ArgumentError, "no such web method '#{method}' on #{this.typed_id}" unless url

  add_classes!(html_attributes, "button remote-method-button #{method}-button")
  label ||= method.titleize
  if update || !ajax_attributes.empty?
    ajax_attributes[:message] ||= label
    func = ajax_updater(url, update, ajax_attributes.merge(:confirm => confirm))
    html_attributes.update(:onclick => "var e = this; " + func, :type =>'button', :value => label)
    element(:input, html_attributes, nil, true, true)
  else
    button_to(label, url, html_attributes.merge(:confirm => confirm))
  end
%></def>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hobo_rapid-1.4.0.pre8 taglibs/buttons/remote_method_button.dryml
hobo_rapid-1.4.0.pre7 taglibs/buttons/remote_method_button.dryml
hobo_rapid-1.4.0.pre6 taglibs/buttons/remote_method_button.dryml
hobo_rapid-1.4.0.pre5 taglibs/buttons/remote_method_button.dryml
hobo_rapid-1.4.0.pre4 taglibs/buttons/remote_method_button.dryml
hobo_rapid-1.4.0.pre3 taglibs/buttons/remote_method_button.dryml
hobo_rapid-1.4.0.pre2 taglibs/buttons/remote_method_button.dryml