简体   繁体   English

Coffeescript和rightjs,Div请点击

[英]Coffeescript & rightjs, Div Click

I am working in sinatra, with Coffeescript and rightjs. 我在sinatra工作,使用Coffeescript和rightjs。

in the body of the html I have a div 在html的正文中,我有一个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? 我希望能够单击ID为loginimage的div并切换页脚元素,现在我可以切换id为id的div,如何选择footer这样的html5元素? What am I doing wrong? 我究竟做错了什么?

I'm not that familiar with RightJS but I suspect that you'd just use a normal <footer> selector in the string: 我对RightJS不太熟悉,但我怀疑您只是在字符串中使用普通的<footer>选择器:

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

No hash ( id selector), no dot (class selector), just the element name. 没有哈希( id选择器),没有点(类选择器),只有元素名称。 The String documentation for RightJS even includes things like this: RightJS的String文档甚至包括以下内容:

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

so presumably the string that you're calling RightJS methods on is just any old selector. 因此,大概您正在调用RightJS方法的字符串就是任何旧的选择器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM