-
-
Save mobz/2602772 to your computer and use it in GitHub Desktop.
Golfing Maria Views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following is sugar for writing out in full a view constructor function, its prototype, and the boilerplate | |
// for inheriting from maria.ElementView. This sugar uses naming conventions to wire together | |
// the view with its model, controller, and their methods. | |
// | |
// A checkit.TodoView will observe a checkit.TodoModel. When the model changes, the update method below is called. | |
// When a user clicks on the todo element, the handling is delegated to the checkit.TodoController's | |
// handleRootClick method. | |
// | |
maria.ElementView.declareConstructor(checkit, 'TodoView', { | |
template: '<li><span class="todo-content"></span></li>', // the template can live elsewhere, of course | |
actions: { | |
'click li': 'handleRootClick' | |
}, | |
methods: { | |
update: function() { | |
this.find('.todo-content').innerHTML = this.getModel().getContent(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment