Sebastian Wramba
Sebastian Wramba

Reputation: 10127

Template contents are not available although template file is loaded

I have this Backbone view defined:

define(["jquery", "backbone", "main", "text!templates/loginViewTemplate.html"], 
  function($, Backbone, loginViewTemplate) {
      var LoginView = Backbone.View.extend({

        render: function() {
              console.log(loginViewTemplate);             
              this.template = _.template(loginViewTemplate, {});              
              $(this.el).html(this.template);
              return this;   
        },

        // ...
     });
 });

But the console.log statement is "undefined", nothing gets rendered. Although I can see a request to the loginViewTemplate.html file in the console. What am I missing?

Upvotes: 1

Views: 30

Answers (1)

Sebastian Wramba
Sebastian Wramba

Reputation: 10127

After getting off the screen for some minutes, I figured out, that the order of dependency declaration is important.

Making the first line look like this solved it:

define(["jquery", "backbone", "text!templates/loginViewTemplate.html", "main"],
  function($, Backbone, loginViewTemplate) {

Upvotes: 1

Related Questions