how to show “hello world” backbone-marionette.js?

Total Post:145

Points:1019
 1347  View(s)
Ratings:
Rate this:

I am trying to trying a view using backbone +backbone-marionette.js..But I am able to get alert in route .But I want to display a view .But I am not able to display my template ?could you please tell me how to show my first view in angular

var firstpage = Backbone.View.extend({

template:"template/firstpage"

})

  1. Post:28

    Points:196
    Re: how to show “hello world” backbone-marionette.js?

    There are many things you have to look at, to display that simple message.

    this will initiate the router on document ready.

    <script>
        $(document).ready(function () {
        router = new routers();
        Backbone.history.start();
    })

    Now in router function we will initialize our View and append it to body

    showFirstPage:function(){
         var fView = new firstpage(); // view initialized
         $('body').append(fView.el); 
        }

    el contains all the events and html , read about it here

    For this to work we have to set some html to el of view on initialize

    var firstpage = Backbone.View.extend({
    template:_.template("<h1>Hello World<h1>"),
    initialize:function(){
        this.$el.html(this.tempalte());
    }
    }) 

      Modified On Apr-09-2018 12:27:01 AM

Answer