# 12. Learn backbone.js tutorial from scratch for beginners(Part 15) More Model Events and listenTo ev

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS4CHICaELL-CIpd2Sh%2F-MS4CZFeT0GYX6hXsunH%2FScreenshot_4.jpg?alt=media\&token=a4573852-2cdc-4418-87cf-d37a542b8a19)

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS4CHICaELL-CIpd2Sh%2F-MS4DmdAZRGsYHdYmObI%2FScreenshot_5.jpg?alt=media\&token=1c707438-d5ce-4b23-b164-df52d3a4562e)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
    	// this.bind('change',function(){
    	// 	console.log('bind change');
    	// });
    	this.bind('change:name',function(){
    		console.log('bind change');
    	});
    }
  });
  fmodel = new FirstModel({
  	
  });
  fmodel.set({
  	name: "Clone fmodel",
  	team: "Solution",
  	age: 10
  });
  var fmodel2 = fmodel.clone();
  var ModelView = Backbone.View.extend({
  	model: fmodel2,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		console.log(this.model.toJSON());
  	},
  });
  vmodel = new ModelView();
});
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS4CHICaELL-CIpd2Sh%2F-MS4EVf6WjkJ3B6syw2z%2FScreenshot_6.jpg?alt=media\&token=22114792-f09f-47c0-a785-77205f7d4a1e)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
    	
    }
  });
  fmodel = new FirstModel({
  	
  });
  fmodel.set({
  	name: "Clone fmodel",
  	team: "Solution",
  	age: 10
  });
  var fmodel2 = fmodel.clone();
  var ModelView = Backbone.View.extend({
  	model: fmodel2,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		fmodel2.set({
  			name: "Change name"
  		});
  		if(fmodel2.hasChanged()) {
  			console.log("hasChanged");
  		}else {
  			console.log("Not hasChanged");
  		}
  	},
  });
  vmodel = new ModelView();
});
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS4E_OEgMoSr17uB_1m%2F-MS4Ey54mSvm8l64lJWY%2FScreenshot_7.jpg?alt=media\&token=451725bf-85fa-4636-980b-44aff9fa402e)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
    	
    }
  });
  fmodel = new FirstModel({
  	
  });
  fmodel.set({
  	name: "Clone fmodel",
  	team: "Solution",
  	age: 10
  });
  var fmodel2 = fmodel.clone();
  var ModelView = Backbone.View.extend({
  	model: fmodel2,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		fmodel2.set({
  			name: "changedAttributes"
  		});
  		if(fmodel2.hasChanged()) {
  			console.log(fmodel2.changedAttributes());
  		}else {
  			console.log("Not hasChanged");
  		}
  	},
  });
  vmodel = new ModelView();
});
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS4F4Q0CkFiN5ra3V4N%2F-MS4FUsrrmI8kJiJUGZ0%2FScreenshot_8.jpg?alt=media\&token=288b7098-6028-4c2c-ba3f-212d58777098)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
    	
    }
  });
  fmodel = new FirstModel({
  	
  });
  fmodel.set({
  	name: "Clone fmodel",
  	team: "Solution",
  	age: 10
  });
  var fmodel2 = fmodel.clone();
  var ModelView = Backbone.View.extend({
  	model: fmodel2,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		fmodel2.set({
  			name: "changedAttributes"
  		});
  		if(fmodel2.hasChanged()) {
  			console.log(fmodel2.previous("name"));
  			console.log(fmodel2.previousAttributes("name"));
  			console.log(fmodel2.changedAttributes());
  		}else {
  			console.log("Not hasChanged");
  		}
  	},
  });
  vmodel = new ModelView();
});
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS4F_iTENrYtokTdLx4%2F-MS4GzYoPrZRp9isdSbp%2FScreenshot_10.jpg?alt=media\&token=48bf9ee3-a2d6-4b8e-b226-7ad91995b47d)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
    	
    }
  });
  fmodel = new FirstModel({
  	
  });
  fmodel.set({
  	name: "Clone fmodel",
  	team: "Solution",
  	age: 10
  });
  var ModelView = Backbone.View.extend({
  	model: fmodel,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		this.listenTo(this.model, 'change',this.listenToModelChange);
  	},
  	listenToModelChange: function() {
  		console.log('listenToModelChange');
  	}
  });
  vmodel = new ModelView();
});
```
