Skip to content

render function called twice #297

@FrancoisDucobu

Description

@FrancoisDucobu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions