0

Seemingly out of nowhere, I'm getting an error thrown on every button click action.

This is the error;

Uncaught TypeError: undefined is not a function

jquery-2.0.2.min.js:5

x.event.dispatch

y.handle

Here is the HTML;

<script id="make-your-bet-template" type="text/template">
    <div class="joinGameWrapper">
        <div id="betSummary"></div>
        <div class="info">
            <label for="inputEachBet">How much will you bet?</label>
            <input id="inputEachBet" type="text" />
        </div>
        <div class="info buttons">
            <button id="btnSendBet" class="btn">Commit</button>
        </div>
    </div>
</script>

Here is the JS (the console.log isn't rending either so I feel like the issue might be here);

onSendBet: function () {
   var data = {
       eachBet : $('#inputEachBet').val() || 'anon'
   };

   IO.socket.emit('playerSentBet', data);

   App.myRole = 'Player';
   App.myBid = data.eachBet;
   console.log('hello');
},

Binding the buttons to functions;

    bindEvents: function () {
        // Host
        App.$doc.on('click', '#btnCreateGame', App.Host.onCreateClick);
        App.$doc.on('click', '#btnPlaceBet', App.Host.onPlaceBetClick);
        App.$doc.on('click', '#btnLockGame', App.Host.onLockGame);

        // Player
        App.$doc.on('click', '#btnJoinGame', App.Player.onJoinClick);
        App.$doc.on('click', '#btnStart',App.Player.onPlayerStartClick);
        App.$doc.on('click', '.btnAnswer',App.Player.onPlayerAnswerClick);
        App.$doc.on('click', '#btnPlayerRestart', App.Player.onPlayerRestart);
        App.$doc.on('click', '#btnSendBet', App.Player.onSendBet);
    },
2
  • is the error being thrown in the onSendBet function or before it? How do you trigger the onSendBet function? Commented Jan 8, 2015 at 1:40
  • The error is being thrown on all buttons, for clarity I have updated the post to display how the buttons are binded. Commented Jan 8, 2015 at 3:12

1 Answer 1

0

Worked it out. The button breaking it all was #btnSendBet. This was assigned to App.Player.onSendBet, however it needed to be assigned to the host. Updating this has resolved all issues.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.