HOW TO SHOW “HELLO WORLD” BACKBONE-MARIONETTE.JS?

ezra heywood

Total Post:145

Points:1019
Posted by  ezra heywood
 962  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. Mark M

    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());

    }

    }) 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!