Method: Alchemy::Admin::BaseHelper#link_to_dialog

Defined in:
app/helpers/alchemy/admin/base_helper.rb

This helper renders the link to an dialog.

We use this for our fancy modal dialogs in the Alchemy cockpit.

Example

<%= link_to_dialog('Edit', edit_product_path, {size: '200x300'}, {class: 'icon_button'}) %>

Parameters:

  • content (String)

    The string inside the link tag

  • url (String or Hash)

    The url of the action displayed inside the dialog.

  • options (Hash) (defaults to: {})

    options for the dialog.

  • html_options (Hash) (defaults to: {})

    HTML options passed to the link_to helper

Options Hash (options):

  • :size (String)

    String with format of “WidthxHeight”. I.E. (“420x280”)

  • :title (String)

    Text for the dialog title bar.

  • :modal (Boolean) — default: true

    Show as modal window.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'app/helpers/alchemy/admin/base_helper.rb', line 52

def link_to_dialog(content, url, options = {}, html_options = {})
  default_options = {modal: true}
  options = default_options.merge(options)
  if html_options[:title]
    tooltip = html_options.delete(:title)
  end
  anchor = link_to(content, url, html_options.merge(
    "data-dialog-options" => options.to_json,
    :is => "alchemy-dialog-link"
  ))
  if tooltip
    ("sl-tooltip", anchor, content: tooltip)
  else
    anchor
  end
end