好的,让我重申一下这个问题。我是Meteor的新手,我不知道如何添加 我创建了一个名为
的流星集合Products1 = new Meteor.Collection ('products1');
在那个系列中我有几个变量,包括:“watts”和“wattsbal”。
这是应用http://orozcotest.meteor.com/products1的一个示例(在此网页中,我必须手动存储“Watts totales”列,方法是将信息存储在{{wats_tot}}
这是我学习如何添加的时候您可以在https://github.com/orozcorp/myapp.git中看到更新的副本,现在我想添加分别由变量“watts”和“wattsbal”标识的列“watts”和“watts balastro”。我还有以下模板
Template.product1Form.events({
'click .save':function(evt,tmpl){
var codigo = tmpl.find('.codigo').value;
var tipo = tmpl.find('.tipo').value;
var watts = tmpl.find('.watts').value;
var wattsbal = tmpl.find('.wattsbal').value;
var watts_tot = tmpl.find('.watts_tot').value;
var precio = tmpl.find('.precio').value;
var precio_bal = tmpl.find('.precio_bal').value;
var numbal = tmpl.find('.numbal').value;
var mo = tmpl.find('.mo').value;
var horasvid = tmpl.find('.horasvid').value;
var lux_watt = tmpl.find('.lux_watt').value;
if(Session.get('editing_product1')){
updateProduct1(codigo,watts, tipo, watts_tot, precio, precio_bal, numbal, mo, horasvid, wattsbal, lux_watt);
} else{
addProduct1(codigo,watts, tipo, watts_tot, precio, precio_bal, numbal, mo, horasvid, wattsbal, lux_watt);
}
Session.set('showProduct1Dialog',false);
Session.set('editing_product1',null);
},
'click .cancel':function(evt,tmpl){
Session.set('showProduct1Dialog',false);
Session.set('editing_product1',null);
},
'click .remove':function(evt,tmpl){
removeProduct1();
Session.set('showProduct1Dialog',false);
Session.set('editing_product1',null);
}
})
现在在我的javascript文件中,我尝试了以下所有方法,并且我一直未定义或NaN
Template.product1Row.helpers ({
wattstotales1 : function(){
var watts = tmpl.find('.watts').value;
var wattsbal=tmpl.find('.wattsbal').value;
var wattstotales = Number(watts) + Number (wattsbal);
return wattstotales;
}
});
Template.product1Row.helpers ({
wattstotales2 : function(){
return Session.get('.watts').value + Session.get('.wattsbal').value;
}
});
Template.product1Row.helpers ({
wattstotales3 : function(){
var watts = find('.watts').value;
var wattsbal = find('.wattsbal').value;
return watts+ wattsbal;
}
});
Template.product1Row.helpers ({
wattstotales4 : function(){
var watts = Session.get(Number('.watts')).value;
var wattsbal = Session.get(Number('.wattsbal')).value;
return watts+ wattsbal;
}
});
Template.product1Row.helpers ({
wattstotales5 : function(){
var watts = Number('watts');
var wattsbal = Number('wattsbal');
return watts+ wattsbal;
}
});
Template.product1Row.helpers ({
wattstotales6 : function(){
var watts = Number(Session.get('.watts').value);
var wattsbal = Number(Session.get('.wattsbal').value);
return watts+ wattsbal;
}
});
Template.product1Row.helpers ({
wattstotales7 : function(){
var watts = Number(Session.get('watts').value);
var wattsbal = Number(Session.get('wattsbal').value);
return watts+ wattsbal;
}
});
Template.product1Row.helpers ({
wattstotales8: function () {
var a = $('products1.watts').val();
var b = $('products1.wattsbal').val();
var total = a+b;
return total;
}
});
Template.product1Row.helpers ({
wattstotales9: function () {
var a = Session.get('products1.watts').val();
var b = Session.get('products1.wattsbal').val();
var total = a+b;
return total;
}
});
Template.product1Row.helpers ({
wattstotales10: function () {
var a = Session.get(Number('products1.watts')).val();
var b = Session.get(Number('products1.wattsbal')).val();
var total = a+b;
return total;
}
});
Template.products1.helpers ({
wattstotales11 : function(){
var watts = tmpl.find('.watts').value;
var wattsbal=tmpl.find('.wattsbal').value;
var wattstotales = Number(watts) + Number (wattsbal);
return wattstotales;
}
});
Template.products1.helpers ({
wattstotales12 : function(){
return Session.get('.watts').value + Session.get('.wattsbal').value;
}
});
Template.products1.helpers ({
wattstotales13 : function(){
var watts = find('.watts').value;
var wattsbal = find('.wattsbal').value;
return watts+ wattsbal;
}
});
Template.products1.helpers ({
wattstotales14 : function(){
var watts = Session.get(Number('.watts')).value;
var wattsbal = Session.get(Number('.wattsbal')).value;
return watts+ wattsbal;
}
});
Template.products1.helpers ({
wattstotales15 : function(){
var watts = Number('watts');
var wattsbal = Number('wattsbal');
return watts+ wattsbal;
}
});
Template.products1.helpers ({
wattstotales16 : function(){
var watts = Number(Session.get('.watts').value);
var wattsbal = Number(Session.get('.wattsbal').value);
return watts+ wattsbal;
}
});
Template.products1.helpers ({
wattstotales17 : function(){
var watts = Number(Session.get('watts').value);
var wattsbal = Number(Session.get('wattsbal').value);
return watts+ wattsbal;
}
});
Template.products1.helpers ({
wattstotales18: function () {
var a = $('products1.watts').val();
var b = $('products1.wattsbal').val();
var total = a+b;
return total;
}
});
Template.products1.helpers ({
wattstotales19: function () {
var a = Session.get('products1.watts').val();
var b = Session.get('products1.wattsbal').val();
var total = a+b;
return total;
}
});
Template.products1.helpers ({
wattstotales20: function () {
var a = Session.get(Number('products1.watts')).val();
var b = Session.get(Number('products1.wattsbal')).val();
var total = a+b;
return total;
}
});
答案 0 :(得分:0)
我终于找到了答案,
Template.product1Row.helpers ({
wattstotales : function (){
var total = Number(this.watts) + Number(this.wattsbal);
return total;
}
})