Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptBackbone.js noConflict Utility

Backbone.js noConflict Utility

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;">
        neveropen
    </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;">
        neveropen
    </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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments