method

button_to_function

Importance_2
v2.1.0 - Show latest stable - 0 notes - Class: ActionView::Helpers::JavaScriptHelper
button_to_function(name, *args, &block) public

Returns a button that’ll trigger a JavaScript function using the onclick handler.

The function argument can be omitted in favor of an update_page block, which evaluates to a string when the template is rendered (instead of making an Ajax request first).

Examples:

  button_to_function "Greeting", "alert('Hello world!')"
  button_to_function "Delete", "if (confirm('Really?')) do_delete()"
  button_to_function "Details" do |page|
    page[:details].visual_effect :toggle_slide
  end
  button_to_function "Details", :class => "details_button" do |page|
    page[:details].visual_effect :toggle_slide
  end
Show source
Register or log in to add new notes.