Created
April 26, 2012 20:54
-
-
Save joncode/2503118 to your computer and use it in GitHub Desktop.
Dead Anchor links in HTML & 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
using a <a href> tag ... | |
<a href="#" id="chooseLink">-tagName</a> | |
using link_to_function (when calling a javascript function instead of link) ... | |
<%= link_to_function "tagName", "javascript function", id: "chooseLink %> | |
using link_to ( changing a link_to to a dead link and then using jQuery to add functionality to id ... | |
<%= link_to "Guitars", {action: 'new', instrument: 'guitar'}, href: '#' %> | |
<%= link_to "Custom Instruments", {action: 'new', instrument: 'custom'},{href: '#', :id => "storeClick" } %> | |
- or - | |
if you have no link options for where to go to preserve ... | |
<%= link_to 'Save in Wishlist',{}, :class => "test" %> | |
if you put the href: '#" in the first block - the rails helper will put the '#' on the url string created | |
rails thinks href: is a params symbol | |
All HTML/CSS related items go in the 2nd block! on link_to | |
If you are using dead link and wanting a jQuery, JS function and you do not want the page to reset ... | |
add return false; | |
to the end of the jQuery / Javascript function | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment