骨干网没有约束力事件的jQuery酥料饼 [英] Backbone not binding events to jQuery Popover
问题描述
此问题似乎类似于那些在其他一些职位要求:这里和<一个href=\"http://stackoverflow.com/questions/5624929/backbone-view-el-confusion/5757160#5757160\">here.我觉得我理解这个概念,但我仍然有问题。
This question seems similar to those asked in a few other posts: here and here. I feel like I understand the concept, but I'm still having issues.
我使用Twitter的引导工具和JavaScript的popovers;该酥料饼是我想要绑定的事件。 JavaScript的插入引导/删除每次调用.popover('秀')/。酥料饼(隐藏)的HTML。绑定到HTML中的酥料饼内的事件不会被调用。从我读,骨干网使用jQuery.delegate()因此,如果HTML存在,它不应该的问题,但事情不能正常工作
I am using the Twitter Bootstrap stuff for javascript popovers; the popover is where I want to bind events. The Bootstrap javascript inserts/removes the html each time you call .popover('show')/.popover('hide'). The events that are bound to the html inside of the popover do not get called. From what I read, Backbone uses jQuery.delegate() so it shouldn't matter if the html exists, but something is not working correctly
events:
"click" : "popover"
"click .close" : "close_popover"
这些事件,首先单击事件的作品,但不是第二个(这是酥料饼内)。
Of these events, the first click event works but not the second (which is inside the popover).
popover: ->
@el.popover('show')
@delegateEvents(@events) #added from link
close_popover: ->
@el.popover('hide')
感谢。
上的jsfiddle的复制问题的工作。添加了code从建议的链接一> - 仍然无法正常工作
Working on a jsFiddle that duplicates the problem. Added the code from the suggested link--still doesn't work.
推荐答案
您code看起来不错。你能否证实与类的元素关闭
存在为您的视图的报
的孩子,这就是你其实再点击? (元素上尝试右击和Chrome开发者工具或Firebug的检查它)。
Your code looks fine. Can you confirm that an element with class close
exists as a child of your view's el
, and that it's what you're actually clicking on? (Try right-clicking on the element and inspecting it with Chrome Developer Tools or Firebug).
这篇关于骨干网没有约束力事件的jQuery酥料饼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!