onclick event inside datatable not firing on the first click
onclick event inside datatable not firing on the first click
eloyfernandes
Posts: 2Questions: 2Answers: 0
Hi, I'm following this tutorial and I'm having a problem with a on click event inside the "on click" of the tr, in one of my table's row I have two anchor tags, but if I want to trigger one of the two i have to click twice the anchor to trigger the event.
$('.approved-datatable').on 'click', 'tr', (e) ->
$('.js-payment-rejected').click ->
payment_document_id = $(this).attr('id')
$.get("#{rejected_payment_payment_documents_path}", payment_document_id: payment_document_id)
$('.js-details').click ->
payment_document_id = $(this).attr('id')
$.get("#{payment_show_payment_documents_path}", payment_document_id: payment_document_id)
how can I trigger the inner event by only clicking once?
Thanks!
This discussion has been closed.
Answers
I'm not that familiar with CoffeeScript (I think that's what your code is?), but from the structure there it looks like you are only adding the click evening to the elements with class names when you activate the first click.
You want to do something like:
Allan