Rails - 动态添加到 sortable_element
我使用 Ajax 添加到可排序列表,并且为了在添加后启动 Scriptaculous 效果,我发现的唯一方法是重新执行 sortable_element。
任何人都可以建议更好的方法来做到这一点,完整的代码是一个黑客:
><%= link_to_remote "Add",
:url => { :controller => "pages", :action => "add_fragment", :pid => pid, :index => index },
:complete => "eval(decodeURIComponent(#{sortable_element 'frag_list', :url => sort_frag_pages_path, :complete => visual_effect(:highlight, 'frag_list'), :handle => 'handle'}).gsub('//',''));" %>
Am adding to a sortable list using Ajax, and to get the Scriptaculous effects to kick in after the add, the only way I have found is by re-executing sortable_element.
Can anyone suggest a better way of doing this, at the complete code is a hack:
><%= link_to_remote "Add",
:url => { :controller => "pages", :action => "add_fragment", :pid => pid, :index => index },
:complete => "eval(decodeURIComponent(#{sortable_element 'frag_list', :url => sort_frag_pages_path, :complete => visual_effect(:highlight, 'frag_list'), :handle => 'handle'}).gsub('//',''));" %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是将其添加到 link_to_remote
page.sortable :frag_list调用的控制器方法中
the answer is to add this into the controller method called by the link_to_remote
page.sortable :frag_list