同一页面上的两个不同的 Yammer 共享按钮

Two different Yammer share buttons on the same page

是否可以将两个不同的 Yammer 共享按钮添加到同一页面?

使用 Yammer I was able to add two buttons to the same page, but they still point to the same url (http://example.com/button2 中的文档和以下配置)。

  yam.platform.yammerShare({
    customButton: true,
    classSelector: 'button1',
    pageUrl: 'http://example.com/button1'
  });
  yam.platform.yammerShare({
    customButton: true,
    classSelector: 'button2',
    pageUrl: 'http://example.com/button2'
  });

我还设置了一个完整的 Plunker here

事实证明事件处理程序本身有一个 API,所以我可以自己进行绑定并获得所需的灵活性:

document.getElementsByClassName('button1')[0].addEventListener('click', function() {
  yam.platform.yammerShareOpenPopup({
    defaultMessage: 'Check out'
    pageUrl: 'http://example.com/button1
  });
});
document.getElementsByClassName('button2')[0].addEventListener('click', function() {
  yam.platform.yammerShareOpenPopup({
    defaultMessage: 'Check out',
    pageUrl: 'http://example.com/button2'
  });
});

当需要更改 url 时,这也更简单,例如由于客户端路由。查看完整的 Plunker here.