Backbone.js noConflict Utility
Last Updated :
23 Aug, 2022
The Backbone.js noConflict Utility is used when we want the Backbone object as its original value. We can use the return value of the Backbone of this function as a reference to the Backbone.
Syntax:
var backbone = Backbone.noConflict() ;
Parameter: This Function doesn’t take any parameter.
Example 1: In this example, we will illustrate Backbone.js noConflict Utility. We will gain the original value of Backbone.js with the help of conflict.
HTML
<!DOCTYPE html>
< head >
< title >BackboneJS noConflict Utility</ title >
< script src =
type = "text/javascript" >
</ script >
< script src =
type = "text/javascript" >
</ script >
< script src =
type = "text/javascript" >
</ script >
</ head >
< body >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h3 >BackboneJS noConflict Utility</ h3 >
< script type = "text/javascript" >
this.Backbone = {
"Hello": "Hello this is not original backbone value"
, VERSION: '1.1.0'
}
</ script >
< script src =
type = "text/javascript" >
</ script >
< script >
var newbackbone = Backbone.noConflict();
console.log(Backbone)
document.write(Backbone["Hello"], `
${Backbone['VERSION']}< br >`);
document.write("Original value of backbone is ",
newbackbone.VERSION);
</ script >
</ body >
</ html >
|
Output:
Backbone.js noConflict Utility
Example 2: In this example, we will use the return original value of Backbone and use its return value reference and create a new Model with it.
HTML
<!DOCTYPE html>
< head >
< title >BackboneJS noConflict Utility</ title >
< script src =
type = "text/javascript" >
</ script >
< script src =
type = "text/javascript" >
</ script >
< script src =
type = "text/javascript" >
</ script >
</ head >
< body >
< h1 style = "color: green;" >
GeeksforGeeks
</ h1 >
< h3 >BackboneJS noConflict Utility</ h3 >
< script type = "text/javascript" >
var newbackbone = Backbone.noConflict();
var model = newbackbone.Model.extend({
initialize: function () {
document.write(
"This is written by reference Backbone");
}
});
var temp = new model();
</ script >
</ body >
</ html >
|
Output:
Backbone.js noConflict Utility
Reference: https://backbonejs.org/#Utility-Backbone-noConflict
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...