javascript - Using jQuery to update the st_url attribute of the sharethis chicklet button? -
i dynamically updating attribute 'st_url' of of sharethis spans url of video clicked jquery. in firebug can see updating st_url attribute of spans, sharethis button still tied initial url. read may have reinit elements, unsure of best way this? has done or have idea of best way re-initialize buttons updated url? thanks!
sharethis includes , init:
<script type="text/javascript"> var switchto5x=true; </script> <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script> <script type="text/javascript"> stlight.options({publisher:'xxxx'}); </script>
my markup:
<span st_url="http://sharethis.com" class='st_stumbleupon' ></span> <span st_url="example" class='st_facebook' ></span> <span st_url="example" class='st_twitter' ></span> <span st_url="example" class='st_email' ></span>
my jquery update attr="st_url" when user clicks on video:
//note: triggered .bind('click') var youtubeid = $(this).attr('id'); $('#container div > span').each(function(){ //update sharethis current video $(this).attr('st_url','http://www.youtube.com/watch?v=' + youtubeid); });
because there's no updateentry call in sharethis need use jquery's .html() recreate elements inside container, repopulate each 1 using individual calls stwidget.addentry against span's id.
here post on sharethis forums answers question in more detail.
Comments
Post a Comment