Reputation: 4118
I am failing to fill my user profile template using Parse.User.Current()
as my model. Without further ado, here is what I have :
HTML
<script type="text/template" id="edit_profile_template">
<h1><%= _.escape(city) %></h1>
<script>
JS - From Backbone's router
new EditProfileView({model: Parse.User.current()});
JS - From EditProfileView
el : "#page_content",
initialize : function() {
this.render();
},
render : function() {
console.log(this.model);
this.$el.html(_.template($("#edit_profile_template", TEMPLATES).html()));
},
this.model
does contain the current user object, but I get city is not defined
from the template. Any idea why?
I am using the exact same syntax for our chat application, using a custom Chat
object instead of Parse.User
, and it is working flawlessly.
IS there any restriction in using Parse.User
as a model for my views?
EDIT
TEMPLATES
here is defined as follows at the entry point of my application :
var TEMPLATES = $("#templates", "body");
I use it to improve the efficiency of the app, so I don't parse the whole DOM every time I am switching views (that is to say all the time :).
Upvotes: 0
Views: 169
Reputation: 863
From what I can tell, it seems as though the data from your model is not being passed into your template. Try something like this -
var tmp = _.template($("#edit_profile_template", TEMPLATES).html());
this.$el.html(tmp(this.model.toJSON()));
I think that may work, assuming the model has a key named city
Upvotes: 1