Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render function called twice #297

Open
FrancoisDucobu opened this issue Aug 23, 2016 · 0 comments
Open

render function called twice #297

FrancoisDucobu opened this issue Aug 23, 2016 · 0 comments

Comments

@FrancoisDucobu
Copy link

FrancoisDucobu commented Aug 23, 2016

Hello,

First, thanks for this awesome plugin.
Setting up sharing button has never been easier.

But I've got a problem with the plugin.

I'm using the 'template' option and for an unknown reason, the render function is call twice.

here

/src/js/jquery.sharrre.js -- line 102

if (self.options.template !== '') {  //for personalized button (with template)
    this.options.render(this, this.options);
}

and here

/src/js/jquery.sharrre.js -- line 203

if (shareCount === this.options.shareTotal) {
    this.options.render(this, this.options);
}

Here is my js

$('#share-button').sharrre({
    share: {
        twitter: true,
        facebook: true
    },
    buttons: {
        facebook: {layout: 'box_count'},
        twitter: {count: 'vertical'}
    },
    title: $(this).data('href'),
    url: $(this).data('url'),
    template: '<ul class="list-inline social-icons"><li><div class="item"><a href="#" class="facebook"><i class="fa fa-facebook"></i></a></div></li><li><div class="item"><a href="#" class="twitter"><i class="fa fa-twitter"></i></a></div></li></ul>',
    enableHover: false,
    enableTracking: false,
    render: function(api, options){
        console.log('render');
    render: function(api, options){
        console.log('render');
        $(api.element)
            .off('click')
            .on('click', '.twitter', function() {
                api.openPopup('twitter');
            })
            .on('click', '.facebook', function() {
                api.openPopup('facebook');
            });
    }
    }
});

to avoid popup opening twice, I add ".off('click')" on the render function.
But I'd rather understand where is my mistake.

Thanks,

Francois

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant