尝试使用引导程序时流星抛出错误

问题描述:

因此,我试图在主页顶部显示所有注册用户作为选项卡(您可以关闭)。为此,我正试图回收这个jisfiddle http://jsfiddle.net/4atm5abf/中的代码。但是,在尝试使用引导程序时,我遇到了错误/问题。尝试使用引导程序时流星抛出错误

这里是我的header.html中是什么样子:

<template name="header"> 
 
    <header class="navbar"> 
 
     <div class="navbar-inner"> 
 
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> 
 
       <span class="icon-bar"></span> 
 
       <span class="icon-bar"></span> 
 
       <span class="icon-bar"></span> 
 
      </a> 
 
      <a class="brand" href="{{pathFor 'userSearch'}}">SocialStore</a> 
 
      {{> listUsers}} 
 
      <div class="nav-collapse collapse"> 
 
       <ul class="nav pull-right"> 
 
        <li>{{>loginButtons}}</li> 
 
        <!-- <li>{{>user_tab}}</li> --> 
 
       </ul> 
 
      </div> 
 
     </div> 
 
    </header> 
 
</template> 
 

 
<template name="listUsers"> 
 
    <div class="container-fluid "> 
 
     {{script}} 
 
     <ul class="nav nav-tabs marginBottom" id="myTab"> 
 
      {{#each Allusers}} 
 
      <li><a href="#profile"><button class="close closeTab" type="button" >×</button>{{username}}</a></li> 
 
      {{/each}} 
 
     </ul> 
 
    </div> 
 
</template>

这里是我的header.js是什么样子:

Template.listUsers.helpers({ 
 
    Allusers: function() { 
 
     return Meteor.users.find().fetch(); 
 
    }, 
 

 
    script: function() { 
 
    var currentTab; 
 
    var composeCount = 0; 
 
    //initilize tabs 
 
    $(function() { 
 
     //when ever any tab is clicked this method will be call 
 
     $("#myTab").on("click", "a", function (e) { 
 
      e.preventDefault(); 
 

 
      $(this).tab('show'); 
 
      $currentTab = $(this); 
 
     }); 
 

 
     registerCloseEvent(); 
 
    }); 
 

 
    function registerCloseEvent() { 
 

 
     $(".closeTab").click(function() { 
 
      //there are multiple elements which has .closeTab icon so close the tab whose close icon is clicked 
 
      var tabContentId = $(this).parent().attr("href"); 
 
      $(this).parent().parent().remove(); //remove li of tab 
 
      $('#myTab a:last').tab('show'); // Select first tab 
 
      $(tabContentId).remove(); //remove respective tab content 
 
     }); 
 
    } 
 

 
    //shows the tab with passed content div id..paramter tabid indicates the div where the content resides 
 
    function showTab(tabId) { 
 
     $('#myTab a[href="#' + tabId + '"]').tab('show'); 
 
    } 
 
    //return current active tab 
 
    function getCurrentTab() { 
 
     return currentTab; 
 
    } 
 

 
    //this will return element from current tab 
 
    //example : if there are two tabs having textarea with same id or same class name then when $("#someId") whill return both the text area from both tabs 
 
    //to take care this situation we need get the element from current tab. 
 
    function getElement(selector) { 
 
     var tabContentId = $currentTab.attr("href"); 
 
     return $("" + tabContentId).find("" + selector); 
 
    } 
 

 
    function removeCurrentTab() { 
 
     var tabContentId = $currentTab.attr("href"); 
 
     $currentTab.parent().remove(); //remove li of tab 
 
     $('#myTab a:last').tab('show'); // Select first tab 
 
     $(tabContentId).remove(); //remove respective tab content 
 
    } 
 
}})

这是我的包文件看起来像:

Meteor packages used by this project, one per line. 
# 
# 'meteor add' and 'meteor remove' will edit this file for you, 
# but you can also edit it by hand. 

insecure 
standard-app-packages 
iron:router 
accounts-base 
accounts-password 
autopublish 
accounts-ui-bootstrap-dropdown 
jquery 

我删除从包引导和增加bootsrap-combined.min.css到/客户/样式表和bootstrap.min.js到LIB /这是两个jsfiddle中使用的示例文件。

这里是我的错误:

=> Modified -- restarting. 
W20141105-20:56:59.640(-8)? (STDERR) 
W20141105-20:56:59.642(-8)? (STDERR) /home/shubham/.meteor/packages/meteor-tool/.1.0.34.m1x0kw++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173 
W20141105-20:56:59.643(-8)? (STDERR)       throw(ex); 
W20141105-20:56:59.643(-8)? (STDERR)        ^
W20141105-20:56:59.644(-8)? (STDERR) ReferenceError: window is not defined 
W20141105-20:56:59.644(-8)? (STDERR)  at app/lib/bootstrap.min.js:6:451 
W20141105-20:56:59.644(-8)? (STDERR)  at app/lib/bootstrap.min.js:8:3 
W20141105-20:56:59.645(-8)? (STDERR)  at /home/shubham/app/.meteor/local/build/programs/server/boot.js:168:10 
W20141105-20:56:59.645(-8)? (STDERR)  at Array.forEach (native) 
W20141105-20:56:59.645(-8)? (STDERR)  at Function._.each._.forEach (/home/shubham/.meteor/packages/meteor-tool/.1.0.34.m1x0kw++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11) 
W20141105-20:56:59.646(-8)? (STDERR)  at /home/shubham/app/.meteor/local/build/programs/server/boot.js:82:5 
=> Exited with code: 8 
=> Your application is crashing. Waiting for file change. 
[=================== ] 95% 31.7s 

我会很感激,如果有人可以告诉我如何使这项工作。由于

+1

Bootstrap v2.2.2!耶稣已经过时了!至少使用2.3.2 ... – cvrebert 2014-11-06 06:14:24

你试过从CDN抓住bootstrap.js并包括: 在任何HTML文件

你有你的定义?

这样你就可以知道它是否是引导程序和流星之间的交互作用,或者你的文件组织是否是问题(不确定它是否可以将bootstrap.js放到lib文件夹中,或者如何将它包含到你的文件夹中html)