CodesJava

Easy learning with example program codes

Backbone.JS View El()

The Backbone.JS View El() method is used to define which element to be used as the view reference.

Syntax:

View.el 

Example:

<!DOCTYPE html>  
<html>
<head>  
<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>  
</head>  
<script type="text/javascript">  
var X = Backbone.View.extend({  
initialize: function(){  
document.write("HELLO WORLD!!");  
}  });  
var Y = new X({ el: $("1") });  
</script> 
<body>  
<div id="1"></div>  
</body>  
</html>

Output:

HELLO WORLD!!

Explanation:
In the above example the El() method defines which element to be used as the view reference.

Please follow and like us:
error









Copyright © 2019 CodesJava DMCA.com Protection Status