Trying to add AddThis to multiple items through JavaScript

Posted by Mantorok on Stack Overflow See other posts from Stack Overflow or by Mantorok
Published on 2010-04-28T10:06:46Z Indexed on 2010/04/28 10:13 UTC
Read the original article Hit count: 434

Filed under:
|
|

I have to add an AddThis chunk to a bunch of controls, the reason I'm doing this through JS is because the addthis: attributes cause XHTML validation errors, so I wrote a JS script that takes the control I want to add the html into and some other bits:

 function AddExternalLinks(control, url, title) {
   $(control).html("<div class'addthis_toolbox addthis_default_style'><a class='addthis_button_facebook'" +
                   " addthis:url=" + url +
                   " addthis:title=" + title +
                   " addthis:description=" + title + "></a>" +
                   "<a class='addthis_button_twitter' " +
                   " addthis:url=" + url +
                   " addthis:title=" + title +
                   " addthis:description=" + title + "></a></div>" +
                   "<script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js#username=cornwallweb'></script>");

However this does not work, the html is added fine but the script fails with the following error:

*c._Queuer is not a constructor
[Break on this error] if(!window._ate){var _atd="www.addthis...(c) 2008, 2009, 2010 Add This, LLC / addthi...wallweb (line 2)

Any ideas? Thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery