试图理解流星
Trying to understand meteor
本文关键字:流星 更新时间:2023-09-26
<head>
<title>bubblePop</title>
</head>
<body>
<center>{{> hello}}<center>
</body>
<template name="hello">
<h1>Bubble Pop!!!!</h1>
{{greeting}}
</template>
我了解车把 {{> hello}} 发生了什么,它基本上是这样您就可以在任何地方插入 {{> hello}},它将与模板中的内容相同。但是我正在尝试使用javascript在我的meteor应用程序上制作一个大表。如何将我的代码放在车把中?我可以在 JS 文件中使用 <template>
吗?只是有点困惑,这是我的其余代码:.JS:
if(Meteor.isClient) {
Meteor.startup(function (){
$(document).ready(function(){
var el;
for(var i=1; i<=64; i++){
el = document.createElement('div');
$(el).addClass('button');
$(el).on('click', function(){
$(this).addClass('removed');
});
$('#container').append(el);
}
});
})
<template name="bubbles">
</template>
Template.hello.greeting = function () {
}
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
.CSS:
#container {
width: 440px;
max-width: 440px;
}
#container > .button {
display: inline-block;
width: 50px;
height: 50px;
background-image: url('http://placehold.it/50x50');
margin-right: 5px;
margin-bottom: 5px;
opacity: 0.85;
transition: all 0.07s ease-in-out;
-moz-transition: all 0.07s ease-in-out;
-webkit-transition: all 0.07s ease-in-out;
cursor: pointer;
}
#container > .button:hover {
opacity: 1;
}
#container > .button.removed {
background-image: none;
}
如何显示所有这些按钮?有些东西我就是得不到
您正在尝试将命令式编程技术应用于响应式范例。
当数据更改时,模板将使用更新的数据隐式重新呈现。
尝试在车把中创建一个简单的循环,并将表绑定到集合。然后,您可以通过集合(或游标(控制行数或行顺序。
请记住,如果将模板绑定到文档,则模板中的this
就是文档。因此,您可以根据方法或成员显示/隐藏按钮。例如。 {{getFirstName}}
就像在说my_document.getFirstName()
.
<table id="comments">
<tr>
<th>One</th>
<th>Two</th>
</tr>
{{#each comments}}
<tr>
<td>{{one}}</td>
<td>{{two}}</td>
</tr>
{{/each}}
</table>
http://handlebarsjs.com/
相关文章:
- 如何使用铁流星与流星的默认路线
- 在流星上使用微信js-sdk时出现拒绝权限错误
- 流星中DOM的繁殖
- 保存串行端口列表与流星
- 我怎么能让流星简单模式中的一个字段等于一个js变量,并且仍然让用户填写简单模式的其余部分
- 流路由器流星的历史
- 动态路径用于流星/铁路由器
- 流星的全球可变范围
- 流星收集更新不是在更新文档
- 在流星中react不工作的defaultValue
- 剑道UI不与流星合作
- 将HTML5模板转换为流星.js,关于js init的问题
- 流星:点击激活其他模板
- 使用流星调用时,可以多次访问流星中的某个函数
- 流星蒙戈的返回阵列
- 如何处理流星变量&对miniMongo有问题
- 流星JS:铁路由器点击按钮
- 我的流星路线出了什么问题
- 流星和铁路由器中的gzip和minimy服务器路由响应
- 在流星中插入嵌套对象