【发布时间】:2015-01-03 12:50:09
【问题描述】:
好的,让我重申一下这个问题。我是 Meteor 的新手,不知道如何添加 我创建了一个名为
的流星集合Products1 = new Meteor.Collection ('products1');
在那个集合中,我有几个变量,包括:“watts”和“wattsbal”。
这是应用程序http://orozcotest.meteor.com/products1 的示例(在此网页中,我必须通过将信息存储在{{wats_tot}} 中手动存储“Watts totales”列,这是在我学习如何添加时暂时)你可以看到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 文件中,我尝试了以下所有方法,但我不断收到 undefined 或 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;
}
});
【问题讨论】:
-
您的辅助函数不返回任何内容。助手拼写为
watts_total而不是wattstotal,并且您显示的代码甚至没有引用您提到的集合。请尽量准确地说明您的要求。
标签: javascript jquery math collections meteor