2014-10-10 68 views
0

如何使用Meteor中的custombox.js插件打開模型彈出框。 它在我的非Meteor頁面上運行良好,現在我似乎無法渲染它。在流星中使用custombox.js打開模態彈出框

我認爲問題是custombox使用jquery的.fn原型,因爲我得到一個未定義的函數錯誤。我嘗試過,因爲它應用在佈局的子模板中(feedsItem反過來是feed的子模板)。

該代碼旨在打開模式彈出式窗口,其中包含有關新聞帖子的更多詳細信息。 的地方點擊時的模式彈出要打開超鏈接的HTML代碼是:

<a href="#modal" class="list-group-item" id="flip">Read More</a> 

和HTML作爲模式彈出打開(關閉的onclick也將是一個事件後。):

<div id="modal" style="display: none;" class="modal-example-content"> 

      <div class="modal-example-header"> 

       <button type="button" class="close" onclick="$.fn.custombox('close');">&times;</button> 

       <h4>Detalhe da Noticia</h4> 

      </div> 

      <div class="modal-example-body"> 

       <p>Lorem Ipsum is simply dummy.</p> 

      </div> 

     </div> 

我的模板事件的代碼是:

Template.feedsItem.events({ 
    'click #flip': function(e){ 
     var flip_position = ['vertical','horizontal']; 
     $.fn.custombox(this, { 
      effect:  'flip', 
      position: flip_position[Math.floor((Math.random()*2))] 
     }); 
     e.preventDefault(); 
    } 
}); 

編輯 我得到了彈出來顯示,但現在我得到一個404錯誤,當它打開。這顯然是因爲它沒有渲染目標div(模態)。 問題是我在一個孩子模板而不是父母(飼料)呈現它。

回答