2012-09-03 50 views
0

我是新來的鬍子,我正在使用它的網站上工作。我在這個網站的一個文件夾中有一組鬍鬚模板。他們被稱爲與Sekizai標籤在主HTML這樣的:鬍子包含模板

<html> 
<head>...</head> 
... 
<body> 

    {% block body_content %}{% endblock %} 

    {% mustachejs "dashboard_module" %} 
    {% mustachejs "dashboard_add_module" %} 
    {% mustachejs "dashboard_empty_module" %} 
    {% mustachejs "login_popup" %} 
    {% mustachejs "add_account_types_popup" %} 
    {% mustachejs "add_account_manual_popup" %} 
    {% mustachejs "add_account_success_popup" %} 
    {% mustachejs "chart_linearprogress" %} 
    {% mustachejs "adviser_popover" %} 

     {% mustachejs "add_event_popup" %} 

</body> 
</html> 

這將產生腳本標籤,如:

<script>Mustache.TEMPLATES=Mustache.TEMPLATES|| 
{};Mustache.TEMPLATES['add_event_popup']='<div id="AddAccountsPopup" class="add-event-popup">\n 
<div class="addAccountsContainer">\n ... </script> 

現在在另一個js文件我想在點擊事件,在這些模板之一,如:

function my func(){ 
      var evnt_btn = $('.add-evnt-btn'); 
      var template; 
      // get mustache template 
     template = $(Mustache.render('add_event_popup')); 

      evnt_btn.click(function(){ 

       template.show(); 
      }); 
} 

什麼是myfunc()當然不工作!我怎樣才能做到這一點?

回答

0

發現:

var template = Mustache.template('add_event_popup').render(null);