2013-05-28 98 views
1

我有一個關於bootstrap的popover和backbone的奇怪問題。backbone和bootstrap js 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> 

應該做的事情代碼:懸停在一個元素(ID =上傳文件)時,則應該是一個popover消息。

代碼實際上在做什麼:當懸停時什麼也沒有發生,但是當單擊該按鈕時骨幹動作會根據需要觸發,但也可以跳過跳轉,但作爲常量元素! scrrenshot taken

謝謝您的幫助( - :

回答

1

時設置了酥料餅,這樣你需要觸發選項:

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

嘗試