I have that action_item on my admin page:
action_item :only => :index do
link_to I18n.t('admin.dem_ref_nvl_etb'), :action => 'whatever'
end
I'd like to know how I could display a pop-up window by clicking that link above, pretty much just like batch_action does when you use it with a "form" option (I don't need such an action here, it's just a basic link).
Any hint ?
Thanks a million for reading and helping!
Building on Hugues's answer, here's a more fleshed-out example that I managed to cobble together with my very meager javascript skills:
In app/assets/javascripts/active_admin.js
:
//= require active_admin/base
$(document).on('ready page:load turbolinks:load', function() {
$('a.lextest').click(function(e) {
e.stopPropagation(); // prevent Rails UJS click event
e.preventDefault();
ActiveAdmin.modal_dialog("Send email to: ", {emails: 'text'}, function(inputs) {alert (inputs.emails)})
})
})
Note that I don't use the default active_admin.js.coffee
because I dislike coffeescript -- just a personal preference. This code adds an onClick event handler to all links with class lextest
. Now you can create such a link with a link_to:
link_to('Modal', '#', class: 'lextest')
I cobbled this all together from the way batch_action
is implemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With