Last active
August 29, 2015 13:56
-
-
Save TechFounder/8876459 to your computer and use it in GitHub Desktop.
A useful jQuery snippet to make any tagged item a clickable link. This is how in Rails.
This file contains 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
[data-link] { | |
cursor: pointer; | |
} |
This file contains 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
ready = -> | |
$("[data-link]").click -> | |
window.location.href = $(this).attr("data-link") | |
false | |
$(document).ready(ready) | |
$(document).on('page:load', ready) |
This file contains 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
<div data-link=<%= the_path %> id="home_div_left"> | |
or | |
<div data-link="http://url.com" id="home_div_left"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment