Answer the question
In order to leave comments, you need to log in
Problem with connecting Require.js (Does not pull the template)
Hello!
There was a problem - require.js does not pull the template at the required url. (Uncaught TypeError: Cannot call method 'replace' of undefined )
When all the templates were in one file, and without require - everything worked.
Here is the dependency code.
routes.js:
r
define([
"pages/RestaurantPage/views/LoginView",
],
function(LoginView, AdminView, CookerView, WaiterView) {
return Backbone.Router.extend({
routes: {
"": "index"
},
index: function() {
loginView = new LoginView;
loginView.render();
}
});});
define([
"underscore",
"backbone",
"jquery",
"text!pages/RestaurantPage/templates/LoginTemplate.html"
],
function(_, Backbone, $, LoginTemplate) {
return Backbone.View.extend({
el: '#content',
render: function() {
var that = this;
var template = _.template($('#loginpage').html());
that.$el.html(template);
}
});
}
);
define([
"underscore",
"backbone",
"jquery",
"text!pages/RestaurantPage/templates/LoginTemplate.html"
],
function(_, Backbone, $, LoginTemplate) {
return Backbone.View.extend({
template: _.template(LoginTemplate),
el: '#content',
render: function() {
this.$el.html(this.template());
return this;
}
});
}
);
Answer the question
In order to leave comments, you need to log in
and if so?
return Backbone.View.extend({
el: $('#content'),
render: function() {
this.$el.html(LoginTemplate);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question