LaF*_*ode 3 activeadmin ruby-on-rails-4
我的管理页面上有action_item:
action_item :only => :index do
link_to I18n.t('admin.dem_ref_nvl_etb'), :action => 'whatever'
end
Run Code Online (Sandbox Code Playgroud)
我想知道如何通过单击上面的链接显示弹出窗口,就像batch_action在使用"form"选项时一样(我不需要这样的动作,它只是基本链接).
任何提示?
万分感谢阅读和帮助!
小智 7
在Hugues的回答的基础上,这是一个更加充实的例子,我设法用我非常微薄的javascript技巧拼凑起来:
在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)})
})
})
Run Code Online (Sandbox Code Playgroud)
请注意,我不使用默认值,active_admin.js.coffee因为我不喜欢coffeescript - 只是个人偏好.此代码将onClick事件处理程序添加到具有类的所有链接lextest.现在,您可以使用link_to创建此类链接:
link_to('Modal', '#', class: 'lextest')
我这个拼凑一起从方式batch_action被实现.
| 归档时间: |
|
| 查看次数: |
5197 次 |
| 最近记录: |