Reputation: 6267
I need to pass a query parameter to my social buttons in click funnels.
It seems they init social shares within a closure. How do I access these elements to change the url of the share buttons?
It does not respect data-url
. I change them, but no effect
Upvotes: 0
Views: 352
Reputation: 6267
data-url
is only read during initialization.
After that, $('.social-likes').data('social-likes')
contains what you need.
Especially .buttons[...].options
!
In the case you want to read an ID from your query and include that in a facebook link.
var someId = window.location.search.match(/someId=([\d]+)/);
someId = someId && someId[1];
var url = 'http://example.com/?someId=' + someId;
$('.social-likes').each(function(){
$($(this).data('social-likes').buttons).each(function(n, button){
console.log('social button button', button);
button.options.url = url;
});
console.log($(this).data('social-likes'));
$(this).data('social-likes').options.url = url;
});
Upvotes: 0