Backbone.js $ Utility is useful when we have multiple jQuery. It is used to specify the particular object as its DOM or AJAX library.
Syntax:
Backbone.$ = $
Properties: This utility cannot takes any parameters.
Example 1: In this example, we will illustrate the Backbone.js $ Utility. Here we will define the utility function default ajax library.
<!DOCTYPE html>
<html>
<head>
<title>BackboneJS $ Utility</title>
<script src="https://code.jquery.com/jquery-1.12.4.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>
<body>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h3>BackboneJS $ Utility</h3>
<script type="text/javascript">
Backbone.$ = $;
console.log(Backbone);
</script>
</body>
</html>
Output:
Example 2: In this example, we will use an object as an AJAX library property.
<!DOCTYPE html>
<html>
<head>
<title>BackboneJS $ Utility</title>
<script src=
"https://code.jquery.com/jquery-1.12.4.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>
<body>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h3>BackboneJS $ Utility</h3>
<script type="text/javascript">
Backbone.$ = {
VERSION : '1.1.0',
emulateHTTP : true ,
emulateJSON : true
};
console.log(Backbone.$);
</script>
</body>
</html>
Output:
Reference: https://backbonejs.org/#Utility-Backbone-$