我安装了羊驼毛和羊驼毛引导装置 mrt添加羊驼 mrt add alpaca-bootstrap
并将alpaca主页的代码放到我的模板中,如下所示: 我无法让它发挥作用。我也尝试过不使用mrt包,把javascript放在不同的文件中......任何人都有线索? THX
<template name="templates">
<div id="content">
<div class="container">
<div class="row">
<!--main content-->
<div class="col-md-12">
<h2 class="title-divider"><span>Templates<span class="de-em"></span></span> <small>What & who makes us tick!</small></h2>
<div id="formxxx"></div>
<script type="text/javascript">
$(function() {
$("#formxxx").alpaca({
"schema": {
"title": "User Feedback",
"description": "What do you think about Alpaca?",
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"ranking": {
"type": "string",
"title": "Ranking",
"enum": ['excellent', 'not too shabby', 'alpaca built my hotrod']
}
}
}
});
});
</script>
</div>
</div>
</div>
</div>
</template>
答案 0 :(得分:0)
Javascript代码不属于模板。您应该将该代码放在“Template.created”事件(http://docs.meteor.com/#template_created)中。
Template.templates.created = function() {
$("#formxxx").alpaca({
"schema": {
"title": "User Feedback",
"description": "What do you think about Alpaca?",
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"ranking": {
"type": "string",
"title": "Ranking",
"enum": ['excellent', 'not too shabby', 'alpaca built my hotrod']
}
}
}
});
};
Template.templates.destroyed = function() {
$("#formxxx").alpaca().destroy(); // never used alpaca so it might not work, but you should destroy any event listeners when the template gets destroyed
};