samedi 4 juillet 2015

Firing a manual click event on an button in ember.js doesn't give the required result

So I am trying to make a custom bot for twitch.tv, only reading his info from the HTML directly. I've got it perfectly working up to the point at where it can recognize commands and put text in the textbox. Now the problem I have is, as soon as I try to fire a manual click event on the "chat" button, it just doesn't seem to work. My guess is it has something to do with ember.js, and I frankly don't know anything about that. Anyway, here is the part of the code that doesn't work.

function pushButton(){
    var chatInterface = document.getElementsByClassName("chat-interface")[0];
    var buttonContain = chatInterface.children[2];
    var button = buttonContain.children[2];
    button.click();
}

What happens here is that I acquire a piece of html that contains the chat submit button, which is this:

<button class="button primary float-right send-chat-button" data-bindattr-3945="3945">
  <span>
    Chat
  </span>
</button>

When I try to manually fire a click event on this, nothing happens. However, when I fire a manual click event on buttonContain.children[0] and buttonContain.children[1] (which are, respectively, the settings and list of viewers buttons), it does work. They look like this:

<a data-ember-action="3943" class="button glyph-only float-left" title="Chat Settings"></a>

I'm guessing the difference is in the data-ember-action and the data-bindattr-*, but I don't know how to make it work. Anyone here knows why the click() event doesn't work and directly clicking does?




Aucun commentaire:

Enregistrer un commentaire