Last active
December 16, 2015 12:38
-
-
Save mynameispj/5435402 to your computer and use it in GitHub Desktop.
Prettier Rails confirm dialogs
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
<%= link_to 'Delete this junk', junk_path(j), :method => :delete, :confirm => 'You sure you want to delete this junk?' %> |
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
$.rails.confirmed = (link) -> | |
linkclass = link.attr 'class' | |
link.removeAttr('data-confirm') | |
link.trigger('click.rails') | |
if linkclass == 'reset-link' | |
window.location.replace(""+link.context.href+""); |
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
$.rails.confirmed = (link) -> | |
link.removeAttr('data-confirm') | |
link.trigger('click.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
<%= link_to 'Reset this junk', reset_junk_path(j), :class => 'reset-link', :confirm => 'You sure you want to reset this junk?' %> |
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
<%= link_to 'Reset this junk', reset_junk_path(j), :confirm => 'You sure you want to reset this junk?' %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if linkclass.indexOf("reset-link") != -1 instead of if linkclass == 'reset-link' if your link_to have more that one class.