mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
and for model destory TODO polyfill TODO mixin
This commit is contained in:
parent
d4e0887bc7
commit
1427ba0e58
3 changed files with 54 additions and 1 deletions
|
@ -201,7 +201,6 @@ var Command = Backbone.Model.extend({
|
|||
},
|
||||
|
||||
addWarning: function(msg) {
|
||||
console.log('this is the warning', msg);
|
||||
this.get('warnings').push(msg);
|
||||
// change numWarnings so the change event fires. This is bizarre -- Backbone can't
|
||||
// detect if an array changes, so adding an element does nothing
|
||||
|
|
|
@ -18,11 +18,17 @@ var CommandView = React.createClass({
|
|||
|
||||
componentDidMount: function() {
|
||||
this.props.command.on('change', this.updateStateFromModel, this);
|
||||
this.props.command.on('destroy', this.onModelDestroy, this);
|
||||
this.updateStateFromModel();
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
this.props.command.off('change', this.updateStateFromModel, this);
|
||||
this.props.command.off('destroy', this.onModelDestroy, this);
|
||||
},
|
||||
|
||||
onModelDestroy: function() {
|
||||
React.unmountComponentAtNode(this.getDOMNode().parentNode);
|
||||
},
|
||||
|
||||
updateStateFromModel: function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue