Class: ActiveAdmin::Views::DropdownMenu

Inherits:
Component
  • Object
show all
Defined in:
lib/active_admin/views/components/dropdown_menu.rb

Overview

Action List - A button with a drop down menu of links

Creating a new action list:

dropdown_menu "Administration" do
  item "Edit Details", edit_details_path
  item "Edit My Account", edit_my_acccount_path
end

This will create a button with the label “Administration” and a drop down once clicked with 2 options.

Instance Method Summary collapse

Instance Method Details

#build(name, options = {}) ⇒ Object

Build a new action list

Parameters:

  • name (String)

    The name to display in the button

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

    A set of options that get passed along to to the parent dom element.


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/active_admin/views/components/dropdown_menu.rb', line 25

def build(name, options = {})
  options = options.dup

  # Easily set options for the button or menu
  button_options  = options.delete(:button) || {}
  menu_options = options.delete(:menu) || {}

  @button  = build_button(name, button_options)
  @menu = build_menu(menu_options)

  super(options)
end

#item(*args) ⇒ Object


38
39
40
41
42
# File 'lib/active_admin/views/components/dropdown_menu.rb', line 38

def item(*args)
  within @menu do
    li link_to(*args)
  end
end