Last active
December 26, 2015 07:09
-
-
Save ichi/7113204 to your computer and use it in GitHub Desktop.
リンクで表示トグル
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
$ -> | |
$(document).on 'click', 'a.toggle', (ev)-> | |
ev.preventDefault() | |
$link = $ @ | |
$target = $ $link.attr 'href' | |
toggle_class = $link.data 'toggle-class' | |
if toggle_class | |
$target.toggleClass(toggle_class) | |
else | |
$target.toggle() | |
# ajax | |
if url = $target.data 'ajax' | |
$target.load url, -> | |
$target.removeAttr 'data-ajax' | |
$target.removeData 'ajax' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment