tolgaergin / social

jQuery plugin for listing profiles and sharing
150 stars 56 forks source link

use attributes of the $('.select') #12

Open aegued opened 7 years ago

aegued commented 7 years ago

This is a good plugin, but i need expand the functions. I have some elements in the page and i want to use the socialShare for everyone for the elements. For example, i assign the attributes to the element to get this on the options:

$('button').socialShare({ social: 'blogger,facebook,google,linkedin,pinterest,twitter',
title: $(this).attr('data-title') });

So, this code not work when a get the title. I need resolve this.

Regards

ahmadGamal commented 7 years ago

$(this) here will return all document object. I faced the same problem, So I override plugin options at socialShare.js file on - obj.click event at line 59 - as following

options.title = obj.attr('data-title');  // object here will return clicked element
options.shareUrl = obj.attr('data-shareUrl');
options.description = obj.attr('data-description');

I know that action not optimal but it fit with my case.