# 9. Learn backbone.js tutorial from scratch for beginners(Part 12) Model Events in backbone.js

![](/files/-MS3dcRmvGhquGGkrayB)

![](/files/-MS3ejG8l0nfAR6Jn6G_)

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

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
      
    }
  });
  fmodel = new FirstModel();
  fmodel.set({
  	name: "<p>Tuong</p>",
  	author: "Lionel Pham"
  });
  var ModelView = Backbone.View.extend({
  	model: fmodel,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {
  		console.log(this.model.escape("name"));
  		console.log(this.model.get("name"));
  		console.log(this.model.toJSON());
  	}
  });
  vmodel = new ModelView();
});
```

![](/files/-MS3fppZPx6p5CzajySq)

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

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
      
    }
  });
  fmodel = new FirstModel();
  fmodel.set({
  	name: "<p>Tuong</p>",
  	author: "Lionel Pham"
  });
  var ModelView = Backbone.View.extend({
  	model: fmodel,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {
  		if(this.model.has("name")) {
  			console.log("Has key");
  		}else {
  			console.log("Has't key");
  		}
  		this.model.unset("name");
  		console.log(this.model.toJSON());
  	}
  });
  vmodel = new ModelView();
});
```

![](/files/-MS3g74Omy2ePPY-_7ft)

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

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
    initialize: function() {
      
    }
  });
  fmodel = new FirstModel();
  fmodel.set({
  	name: "<p>Tuong</p>",
  	author: "Lionel Pham"
  });
  var ModelView = Backbone.View.extend({
  	model: fmodel,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {
  		if(this.model.has("name")) {
  			console.log("Has key");
  		}else {
  			console.log("Has't key");
  		}
  		// this.model.unset("name");
  		this.model.clear("name");
  		console.log(this.model.toJSON());
  	}
  });
  vmodel = new ModelView();
});
```

![](/files/-MS3hcOquu16tXB0tFYy)

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
  	defaults: {
    	name: 'first',
    	author: 'Default Author', 
    },
    initialize: function() {
      
    }
  });
  fmodel = new FirstModel({
  	
  });
  fmodel.set({
  	name: "<p>Tuong</p>"
  });
  var ModelView = Backbone.View.extend({
  	model: fmodel,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {
  		console.log(this.model.toJSON());
  	}
  });
  vmodel = new ModelView();
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascriptuse.gitbook.io/advanced/12.-learn-backbone.js-tutorial-from-scratch-for-beginners-part-12-model-events-in-backbone.js.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
