简体   繁体   中英

How do you add an input search field in an ActiveAdmin menu or header

I am trying to add a search field into the ActiveAdmin header. I would prefer it to be next to the logout button in ActiveAdmin, but I'd settle for it being anywhere in the header. I've tried using admin.build_menu with no luck. I don't want to use sidebars since it would eat into my horizontal space.

It would be great to be able to do something like this:

config.namespace :admin do |admin|
  admin.build_menu do |menu|
    menu.add :input => 'Search', :url => "/search"
  end
end

and have it place a search box in the menu bar

Any help on this would be appreciated. I'd like to do this as cleanly as possible without overriding ActiveAdmin code, but I'm willing to entertain any solution.

The solution I implemented is via jQuery. Added this line on active_admin.js:

$('#header ul#tabs').append('<li><input id="listing-search" type="text" placeholder="Listing Number"></input></li>');

Then handle the event correspondingly (via JS of course). 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM