Data-generated widgets fail to recognize passed in IDs
sjwilliams opened this issue · comments
Josh Williams commented
_prepItem generates a domID, even if you pass in an id via the content array
$('#container').ScrollStory({
content: [{hed:'Headline1', id:'myid1'}, {hed, 'Headline2', id: 'myid2'}]
itembuild: function(ev, data) {
data.item.el.html('<h2>'+data.item.domData.hed+'</h2>');
}
});
_prepItem should probably be something like this:
// use exisiting ID or generate a new one
if ($el.attr('id')) {
id = $el.attr('id');
} else if (data.id) {
id = data.id;
$el.attr('id', id);
} else {
id = 'scrollStory_story_' + index;
$el.attr('id', id);
}