骨干和bootstrap js popover

时间:2013-05-28 09:35:30

标签: twitter-bootstrap backbone.js

我对bootstrap的popover和骨干有一个奇怪的问题。

我的骨干代码:

App.Views.UploadBox = Backbone.View.extend({
el: '#upload-box',

events: {
    'click #upload-file': 'openPicker',
    'change #upload-file-input': 'handleFileUpload'
    //'mouseover #upload-file': 'hoverMessage'

},

initialize: function () {
    this.uploader = this.$('#upload-file-input');
    this.$("#upload-file").popover({ title: 'some title', content: 'helo world' });
    this.button = this.$('#upload-file');
}, ...

上传框:

<div class="span2 offset1" id="cannon-upload-box">
  <a href="#" class="btn media-header span10" 
  id="upload-file" rel="popover">UploadFile</a>
  <input id="upload-file-input" 
  type="file" placeholder="Choose File" style="display: none">
</div>

代码应该做什么:当将鼠标悬停在a元素(id = upload-file)上时,应该是一个弹出消息。

代码实际在做什么:当悬停没有任何反应时,但是当单击按钮时,骨干操作会根据需要被触发,但也会弹出跳转但作为常量元素!scrrenshot taken

感谢您的帮助( - :

1 个答案:

答案 0 :(得分:1)

设置弹出框时需要触发选项,如下所示:

this.$("#upload-file").popover({ 
    title: 'some title',
    content: 'helo world' ,
    trigger: 'hover' // show up on hover default is 'click'
});
试试吧!