Dustin Falgout
Dustin Falgout

Reputation: 123

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);
});

Upvotes: 1

Views: 45

Answers (2)

curran
curran

Reputation: 1316

You can also add the function to app.proto, like this:

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

This is based on how a helper function is added in the TODO example.

Upvotes: 0

Dustin Falgout
Dustin Falgout

Reputation: 123

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>

Upvotes: 1

Related Questions