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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -