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

Livefyre trigger Post Comments button via another button

本文关键字:按钮 Post Comments livefire 另一个      更新时间:2023-09-26

我正在开发一个自定义笔记应用程序,当在作者的网站上单击"post note as Livefyre comment"时,应该能够将其内容发布到Livefyre。

我一直试图通过Javascript在外部触发Livefyre小部件上的"Post as comment"按钮,但它没有点击它…

Livefyre Post Comment 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");
});

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

谢谢!

解决方案是在另一个DOM元素的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