我想实现 AddThis Toolbox
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<attribute ca:name="addthis:url">http://www.foobar.org </attribute>
<attribute ca:name="addthis:title">An excellent website</attribute>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_email"></a>
</div>
变成这样,这是我的代码,我只将我的主页标题放入 Twitter 框中。它通常可以工作,但属性未集成!
Div oDivAddThis = new Div();
oDivAddThis.setClass("addthis_toolbox addthis_default_style addthis_style");
oDivAddThis.setAttribute("ca:name='addthis:url'", "https://www.test.org");
oDivAddThis.setAttribute("ca:name='addthis:title'",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
oDivAddThis.setAttribute("addthis:url", "https://test.org.com/?cp="+oSearchDAO.getImage().trim());
oDivAddThis.setAttribute("addthis:title",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
A compGooglePlus = new A();
compGooglePlus.setClass("addthis_button_google_plusone_share");
compGooglePlus.setAttribute("addthis:url", "https://test.org.com/?cp="+oSearchDAO.getImage().trim());
compGooglePlus.setAttribute("addthis:title",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
A compFacebook = new A();
compFacebook.setClass("addthis_button_facebook");
A compTwitter = new A();
compTwitter.setClass("addthis_button_twitter");
compTwitter.setAttribute("addthis:url", "https://test.org.com/?cp="+oSearchDAO.getImage().trim());
compTwitter.setAttribute("addthis:title",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
A compCompact = new A();
compCompact.setClass("addthis_button_compact");
compGooglePlus.setParent(oDivAddThis);
compFacebook.setParent(oDivAddThis);
compTwitter.setParent(oDivAddThis);
compCompact.setParent(oDivAddThis);
我什至尝试过这样的事情(客户端/属性命名空间)
oDivAddThis.setAttribute("ca:name='addthis:url'", "https://test.org/?cp="+oSearchDAO.getImage().trim());
oDivAddThis.setAttribute("ca:name='addthis:title'",oSearchDAO.getTitle()+" \n "+oSearchDAO.getDescription1()+" \n "+oSearchDAO.getDescription2());
任何帮助表示赞赏,谢谢
更新 [已解决]
在托尼(http://zkfiddle.org的作者)的帮助下,我得到了它的工作。我的错误是我使用了在服务器端明确评估的 setAttibute。
我所要做的就是使用 setWidgetAttibute ,它将在客户端进行评估,这就是它。:-) 惊人。感谢 victor 发布您的想法,并特别感谢对我帮助很大的 Tony。