0

I am working in sinatra, with Coffeescript and rightjs.

in the body of the html I have a div

<div id="loginimage">
<img src="/images/login.png">
</div>

and a footer element

<footer>
<div id="footer">
<form action="/login" class="login" method="post">
</form>
</div>
</footer>

and finally my coffee script looks like:

$(document).onReady ->
  "#loginimage".onClick ->
    "#footer".toggle "fade"

I want to be able to click on the div with id loginimage and toggle the footer element, right now I have it toggling the div with id footer, how can I select html5 elements like footer? What am I doing wrong?

Theta
  • 175
  • 8

1 Answers1

1

I'm not that familiar with RightJS but I suspect that you'd just use a normal <footer> selector in the string:

$(document).onReady ->
  "#loginimage".onClick ->
    "footer".toggle "fade"

No hash (id selector), no dot (class selector), just the element name. The String documentation for RightJS even includes things like this:

"div.something".addClass('marked');
"div#something".highlight();

so presumably the string that you're calling RightJS methods on is just any old selector.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
  • Yeah, I was about to post http://rightjs.org/tutorials/what-new-in-rjs2#events-delegation. The String class now has all the same API for events handling as the Element unit. – Theta Jul 07 '12 at 19:15