I've read a few post here concerning my issue but I don't know how to apply that to my code since I don't work with an array or other object.
In Safari I get this error:
TypeError: undefined is not an object (evaluating '$('#related .expansion').data('handle').replace')
I have a function that populates a select dynamically, like so:
function expansieRubberSelect(){
var url = $('#related .expansion').data('handle').replace('.html', '.ajax');
$.getJSON(url, function(data){
var select = '';
$.each(data.variants, function (index, variant) {
select += '<option value="'+variant.id+'" data-size="'+variant.title.replace(/\D/g,'')+'" data-price="'+variant.price.price_excl.toFixed(2)+'" data-priceincl="'+variant.price.price+'">'+variant.title+'</option>'
});
$("#related .expansion select").append(select);
});
}
And then in my doc ready I call it like so:
$(function(){
expansieRubberSelect()
});
I've read that missing an object is causing the problem obviously. However I don't have a clue how that would apply to my code.
Do I need to change the select to an array or something? And then call in like expansieRubberSelect(mySelect)
?
Any help appreciated!