Search code examples
derbyjs

Derbyjs v0.6 app.fn() doesn't exist


I'm following the Multi-Payer Notepad game tutorial on youtube and can't get the x-bind to work, because I get the following error:

app.fn('startGame', function(e, el) {
    ^
TypeError: Object #<App> has no method 'fn'

I'm assuming this method was changed in v0.6, since it just came out. Does anyone know the new way to complete this binding? This is what app.fn is doing:

app.fn('startGame', function(e, el) {
  var userId = model.get('_session.userId');
  this.model.set('_page.story.ready.' + userId, true);
});

Solution

  • app.component('story', Story);
    
    function Story(){};
    
    Story.prototype.startGame = function() {
      alert('clicked!');
      var userId = this.model.get('_session.userId');
      this.model.set('_page.story.ready.' + userId, true);
    };
    

    story.html

    <button type="button" on-click="startGame()">Click when you're ready</button>