Thursday, 19 September 2013

Is this a javascript method or property?

Is this a javascript method or property?

I'm having the hardest time getting my terminology right. In the following
code:
Notes.NotesController = Ember.ArrayController.extend({
newNoteName: null,
actions: {
createNewNote: function() {
var content = this.get('content');
var newNoteName = this.get('newNoteName');
var unique = newNoteName != null && newNoteName.length > 1;
content.forEach(function(note) {
if (newNoteName === note.get('name')) {
unique = false; return;
}
});
if (unique) {
var newNote = this.store.createRecord('note');
newNote.set('id', newNoteName);
newNote.set('name', newNoteName);
newNote.save();
this.set('newNoteName', null);
} else {
alert('Note must have a unique name of at least 2 characters!');
}
}
}
});
What is 'newNoteName:', 'actions:', and 'createNewNote:'?
Are they methods or properties or hooks? What are the differences? And
does 'createNewNote' being nested inside of 'actions:' make 'actions'
something altogether different?
What is the difference between ember 'hooks' and methods/properties that
you create and name yourself and how they're used?
Thank you.'

No comments:

Post a Comment