I have a structure like this and I'm using Share-Button
<div class="video-snap">
<div class="video-content">All the content is here</div>
<div class="share-button" data-url="video1">
</div>
<div class="video-snap">
<div class="video-content">All the content is here</div>
<div class="share-button" data-url="video2">
</div>
I need that each share button share the data-url indicated on data field. I came up with this but the result is that even on console the each works good (I get all the urls correctly) The URL assigned to the button is always the last one of the video-snap elements (all would go to video2 url in this example)
$(window).load(function() {
$('.video-snap').each(function() {
var url = $('.share-button', this).data('url');
console.log(url);
config = {
networks: {
facebook:{
url: url
},
google_plus:{
url: url
},
twitter:{
url: url
},
pinterest:{
enabled: false
},
email:{
enabled: false
}
}
}
new Share('.share-button', config)
});
});
What I'm looking for and can't achieve is that each share-button has it's own url. Not sure what I'm doing wrong since I'm using the each function.