-1
好的,让我重申一下这个问题。我在新的流星,我不知道如何添加 我创建了一个流星集合称为在同一个集合中添加两个项目
Products1 = new Meteor.Collection ('products1');
和收集我有几个变量,其中包括:“瓦”和“wattsbal”。
这是应用http://orozcotest.meteor.com/products1的样品(在这个网页我不得不手动列“瓦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;
}
});
你的帮助函数不返回任何东西。该助手拼写'watts_total'而不是'wattstotal',并且您显示的代码甚至不涉及您提到的集合。请尝试更精确地询问你的要求。 – 2014-11-06 22:38:32