Trigger a click with jQuery using link_to of rails 4

后端 未结 2 1572
滥情空心
滥情空心 2020-12-21 06:09

I\'m working on a Rails 4 app. I need to trigger a click in a link using javascript (or jQuery). I have this in my view:

<%= link_to t(\'.fixture\'), fixt         


        
相关标签:
2条回答
  • 2020-12-21 06:58

    Solved! I've solved this by loading the correct JS and executing it directly, using the 'active' parameter and without need a click on the links. Thanks to everyone who helped me!

    If someone wants to know, this is the code I've used (its coffeescript):

    tournament = $('#main-wrapper').data('tournament')
    $.get '/manager/tournaments/' + tournament + '/fixture.js', (data) -> data
    
    0 讨论(0)
  • 2020-12-21 07:00

    Though its very late and you have got your problem solved, but here is the actual solution :)

    $('#fixture-link')[0].click();
    

    You missed [0] portion.

    0 讨论(0)
提交回复
热议问题