Monday, 9 September 2013

javascript array/object.push not working

javascript array/object.push not working

input:
var variants = [];
$("div.product[data-variant]").each(function() {
variants = [{name:chocolate, url:http://urltochocolate.de;
});
output:
$.each(optionList, function (i, el) {
combo.append('<option value="'+ el.url +'">' + el.name + "</option>");
});
the above version works, but if i want to save all variants not only the
last by adding a variants.push it won't work. i know push is an array
function but how does it work for JS objects? or does a push work but then
i use the wrong output function?
any help appreciated, it can't be so difficult, just not seeing the
solution :(

No comments:

Post a Comment