1
因此,我試圖在主頁頂部顯示所有註冊用戶作爲選項卡(您可以關閉)。爲此,我正試圖回收這個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
我會很感激,如果有人可以告訴我如何使這項工作。由於
Bootstrap v2.2.2!耶穌已經過時了!至少使用2.3.2 ... – cvrebert 2014-11-06 06:14:24