Created
June 16, 2013 12:45
-
-
Save iboard/5791932 to your computer and use it in GitHub Desktop.
Handle click on a table-row with Rails4 and coffeescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WORKS THE FIRST TIME BUT FAILES WHEN RETURNING TO THE PAGE UNLESS RELOADING | |
jQuery -> | |
$('.clickable-row td').click -> | |
target_id = $(this).parent().attr('id').replace /row-id-/,'' | |
document.location = "/controller_xy/#{target_id}/edit" | |
# WORKS FINE EVERY TIME | |
jQuery -> | |
$(document).on( 'click', '.clickable-row td', -> | |
table_row = $(this).parent() | |
target_id = table_row.attr('id').replace /row-id-/, '' | |
document.location = "/players/#{target_id}/edit" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment