8000 Batch action with turbolinks attaching click event twice · Issue #5553 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip 6474 to content
Batch action with turbolinks attaching click event twice #5553
Closed
@sgara

Description

@sgara

Hi,
We'be been using activeadmin with turbolinks quite successfully for some time. While migrating to Turbolinks 5, I encountered an issue on batch actions : seems like both ready and turbolinks:load are trigger, which causes click handler to be attached twice.

I've recreated a simple project from scratch to check if that wasn't coming from our side and I do reproduce it. Basically just a brand new default rails app with activeadmin. Source code and live demo are available. Just go to admin/items directly, select items then Batch Actions > Delete Selected Items. The modal is then opened twice as you can see in this screenshot :
screenshot 2018-11-08 at 22 45 28

Looks like every version between 1.0.0 and 1.3.1 are affected (master might be as well). A possible solution would be to detach previously attached click handler here like this :

$('.batch_actions_selector li a').off('click').on 'click', (e)->

I'd be happy to do a PR if that solution seems acceptable. I'm open to other solutions/workarounds/.. as well.
Best!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0