javascript - Dynamically changing url in sharrre Jquery -


my question following:

i have multiple filters on page, filter events schedule dynamically, when click on of filters, url changes without reloading page.

for example:

http://.../schedule/#screening,free

http://.../schedule/#talk,expo

then, have share buttons sharrre:

    .social.social--share-filters         a.icon.icon-twitter.js-twitter-filters(href="#", target="_blank")         a.icon.icon-linkedin2.js-linkedin-filters(href="#", target="_blank")         a.icon.icon-facebook.js-facebook-filters(href="#", target="_blank") 

  $('.js-facebook-filters').sharrre({ share: {   facebook: true, }, url: window.location.href, enabletracking: false, enablehover: false, click: function(api, options) {   api.simulateclick();   api.openpopup('facebook'); }   }); 

inspite of fact inside sharrre have url variable equals current link, shares link derived when page loaded first time.

i tried put inside click event on icons - not work. tried put sharrre inside function (eg. initialiseshare) , window.initialiseshare = initialiseshare; - not work. , tried remove , append button, changing data-url attribute, , not work.

function initialiseshare(link) {     $('.js-twitter-filters').sharrre({     share: {       twitter: true,     },     enabletracking: false,     enablehover: false,     click: function(api, options) {       api.simulateclick();       api.openpopup('twitter');     }   }); } 

+

$(document).ready(function() {     initialiseshare();     $('.js-twitter-filters').on('click', function(){         var clone = $('.js-twitter-filters').clone();         $('.js-twitter-filters').remove();         $('.social--share-filters').append(clone);         $('.js-twitter-filters').data('url', window.location.href);         initialiseshare();         return false;     }); }); 

+

jade icon

    .social.social--share-filters         a.icon.icon-twitter.js-twitter-filters(href="#", target="_blank" data-url="#") 

please, help!

thank in advance!

p.s. can use other solution except lead buttons cannot customised in design.

try this:

$('body').on('domnodeinserted', '.js-twitter-filters', function(e) {   $(this).sharrre({     share: {       twitter: true,     },     enabletracking: false,     enablehover: false,     click: function(api, options) {       api.simulateclick();       api.openpopup('twitter');     }   }); }); 

explanation:

you're trying bind dynamically loaded elements. when script executes on page load, elements not available jquery perform binding "sharrre" - can use .on() live binding delegate bind elements after insertion.

reference:


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -