Livefyre trigger Post Comments button via another button

147 views Asked by At

I am working on a custom notes application that should be able to post its contents to Livefyre when clicking "post note as livefyre comment" to the author's site.

I've been trying to trigger the "Post as comment" button on the Livefyre widget externally via Javascript and it's not clicking it...

The 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 part to trigger:

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

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

Has anyone tried this? or is this possible at all? I hope someone can help!

Thanks!

1

There are 1 answers

0
Gibron On

The solution would be to call the click event for the DOM element of interest within the click event handler of another.

The JS could look like:

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

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

A working example: http://codepen.io/gibron/pen/AzKGj?editors=101