Backbone.JS Escape()

The Backbone.JS Escape() model is used to get the html-escaped version of a model’s attributes.

Syntax:

Model.Escape(attribute)   

Parameters:
attribute: This parameter is used to define properties of a model.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<title>Example</title>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js" type="text/javascript"></script>
<script type="text/javascript">
var X = Backbone.Model.extend();
var Y = new X();
Y.Escape({ MSG1: "HELLO", MSG2: "WORLD"});
document.write("The FIRST Message: ", Y.escape('MSG1'));
</script>
<!-- Mirrored from www.w3schools.blog/backbonejs-escape by HTTrack Website Copier/3.x [XR/YP'2000] -->
<title>Example</title> <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js" type="text/javascript"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js" type="text/javascript"></script> <script type="text/javascript"> var X = Backbone.Model.extend(); var Y = new X(); Y.Escape({ MSG1: "HELLO", MSG2: "WORLD"}); document.write("The FIRST Message: ", Y.escape('MSG1')); </script> <!-- Mirrored from www.w3schools.blog/backbonejs-escape by HTTrack Website Copier/3.x [XR/YP'2000] -->
  
 
   
Example  
  
  
  
  
  


  

Output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
The FIRST Message: HELLO
The FIRST Message: HELLO
The FIRST Message: HELLO

Explanation:
The Backbone.JS Escape() model gets the html-escaped version of the attributes in the model.