admin管理员组文章数量:1327996
I know other posts have been made regarding this, but so far the answers I've seen have not been helpful, and slightly different from my situation.
window.BotView = Backbone.View.extend
initialize: ->
_.bindAll @, 'alert', 'render'
@el # by calling this here, it initializes the jQuery object
el: $("#submit")
model: Chatbot
events:
"click #submit" : "alert"
alert: ->
console.log("alert called")
alert("event observed")
render: ->
alert("Rendered")
jQuery ->
window.App = new BotView
console.log App.el
All I want is when I click on the submit button with the id
of submit
for it to fire the alert
function. However, I can't even get this to work.
What is going on with the events
that my simple click
handler on #submit
isn't working?
I have double checked that my el
is properly initialized, but even so, it should not matter because the click handler is not using el
Could anyone shed some light on why this simple event is not firing?
Thanks in advance
I know other posts have been made regarding this, but so far the answers I've seen have not been helpful, and slightly different from my situation.
window.BotView = Backbone.View.extend
initialize: ->
_.bindAll @, 'alert', 'render'
@el # by calling this here, it initializes the jQuery object
el: $("#submit")
model: Chatbot
events:
"click #submit" : "alert"
alert: ->
console.log("alert called")
alert("event observed")
render: ->
alert("Rendered")
jQuery ->
window.App = new BotView
console.log App.el
All I want is when I click on the submit button with the id
of submit
for it to fire the alert
function. However, I can't even get this to work.
What is going on with the events
that my simple click
handler on #submit
isn't working?
I have double checked that my el
is properly initialized, but even so, it should not matter because the click handler is not using el
Could anyone shed some light on why this simple event is not firing?
Thanks in advance
Share Improve this question asked Oct 3, 2011 at 2:57 BenBen 5631 gold badge13 silver badges25 bronze badges1 Answer
Reset to default 8In your events you are saying, in the #submit element, look for an element that gets clicked with the ID of #submit. Change it to
'click' : 'alert'
and it should work fine.
The jQuery equivalent of what you have above is this:
$('#submit').find('#submit').click(alert);
本文标签: javascriptBackbone events not firingStack Overflow
版权声明:本文标题:javascript - Backbone events not firing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742249137a2440418.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论