Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Different Pages For Different Routes In Backbone

         <script type="text/javascript">  
         var Route1 = Backbone.View.extend({  
  
            template: '<b>This is route 1</b>',  
               initialize: function () {  
                  this.execute();  
               },  
  execute: function () {  
                  this.$el.html(this.template);  
               }  
         });  
         var Route2 = Backbone.View.extend({  
            template: '<b>This is route 2</b>',  
               initialize: function () {  
                  this.execute();  
               },  
               execute: function () {  
                  this.$el.html(this.template);  
               }  
        });  
  
        var AppRouter = Backbone.Router.extend({  
           routes: {  
              '': 'homeRoute',  
              'route/1': 'homeRoute',  
              'route/2': 'aboutRoute',  
           },  
  
           homeRoute: function () {  
              var route1 = new Route1();  
              $("#content").html(route1.el);  
           },  
  
           aboutRoute: function () {  
              var route2 = new Route2();  
              $("#content").html(route2.el);  
           }  
       });  
       var appRouter = new AppRouter();     
  
       Backbone.history.start();  
       </script>  
     </head>  
  <body>  
       
    <div id="navigation">  
       <a href="#/route/1">route1</a>  
       <a href="#/route/2">route2</a>  
    </div>  
    <div id="content"></div>  
  </body>  
Comment

PREVIOUS NEXT
Code Example
Javascript :: Backbone Router Notes 
Javascript :: Using Fetched Data With Backbone 
Javascript :: country select dropdown javascript 
Javascript :: merge large arrays 
Javascript :: React Gotchas 
Javascript :: add even javascript 
Javascript :: create number format excel react native 
Javascript :: use strict print this 
Javascript :: event 
Javascript :: hide and show button react js 
Javascript :: react native raw bottom sheet 
Javascript :: javascript binary tree 
Javascript :: js 
Javascript :: javascript interview questions interviewbit 
Javascript :: mongoose schema for nested items 
Javascript :: moment format dates 
Javascript :: getcontext in javascript 
Javascript :: react native get screen height and width 
Javascript :: how to add prefix to a string in javascript 
Javascript :: javascript copy text by id to clipboard 
Javascript :: js spin wheel color 
Javascript :: javascript Remove Element from Inner Array 
Javascript :: javascript of the object properties to a single variable 
Javascript :: JavaScript Comparison and Logical Operators 
Javascript :: simple counter with react hook 
Javascript :: query middleware in express 
Javascript :: change origin xy phaser 
Javascript :: phaser animation get progress 
Javascript :: refresh secounds 
Javascript :: angular reactive forms bootstrap 4 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =