Livefyre通过另一个按钮触发Post Comments按钮

时间:2014-07-25 11:41:48

标签: javascript jquery livefyre

我正在开发一个自定义笔记应用程序,该应用程序应该能够在将“发布笔记作为livefyre评论”点击到作者网站时将其内容发布到Livefyre。

我一直试图通过Javascript在外部触发Livefyre小部件上的“发布为评论”按钮,而不是点击它...

Livefyre发表评论HTML:

<div class="goog-inline-block fyre-button-right fyre-post-button fyre-post-button-new" role="button" style="-moz-user-select: none;" id=":2n">
  <div class="goog-inline-block fyre-button-right-outer-box">
   <div class="goog-inline-block fyre-button-right-inner-box">Post comment</div>
  </div>
</div>

要触发的Javascript部分:

<a href="#" id="post_comment">POST COMMENT TRIGGER</a>

$("#post_comment").click(function(){
  $(".fyre-post-button-new").trigger("click");
});

有人试过吗?或者这有可能吗? 我希望有人可以帮忙!

谢谢!

1 个答案:

答案 0 :(得分:0)

解决方案是在另一个的click事件处理程序中调用感兴趣的DOM元素的click事件。

JS看起来像:

$(".fyre-post-button-new").click(function(){
   alert("Post new button was clicked.") 
});

$("#post_comment").click(function(){
  $(".fyre-post-button-new").click();
});

一个工作示例:http://codepen.io/gibron/pen/AzKGj?editors=101