jquery - more less example with coffeescript -
i'm trying add basic more/less links toggle element visibility.
how insert preventdefault
?
also works on first toggle, after doesn't toggle out. error?
$("#description-link").click -> $("#project-description").show() $(this).text("show description") , -> $("#project-description").hide() $(this).text("hide description")
well, try instead:
$("#description-link").click (e) -> e.preventdefault() $('#project-description').toggle() = $(this).text() = if (a == 'show details') 'hide details' else 'show details' $(this).text(a)
and apparently space between click
, (e)
required. otherwise typeerror thrown.
edit: realized why space required...as it's part of function declaration. haven't messed coffeescript before. /facepalm
Comments
Post a Comment