user profile display improvements

pull/576/head
Justin Richer 2014-03-02 01:12:47 +00:00
parent f8e82037fe
commit 485e17c893
2 changed files with 12 additions and 33 deletions

View File

@ -317,6 +317,9 @@ var UserProfileView = Backbone.View.extend({
tagName: 'span',
initialize:function() {
if (!this.template) {
this.template = _.template($('#tmpl-user-profile-element').html());
}
},
render:function() {
@ -324,34 +327,17 @@ var UserProfileView = Backbone.View.extend({
$(this.el).html($('#tmpl-user-profile').html());
_.each(this.model, function (value, key) {
$("fieldset",this.el).append(
new UserProfileElementView({
model:{key: key, value: value}
}).render().el);
if (key && value) {
$('dl', this.el).append(
this.template({key: key, value: value})
);
}
}, this);
return this;
}
});
var UserProfileElementView = Backbone.View.extend({
tagName: 'div',
initialize:function() {
if (!this.template) {
this.template = _.template($('#tmpl-user-profile-element').html());
}
},
render:function() {
$(this.el).html(this.template(this.model));
return this;
}
});
// Router
var AppRouter = Backbone.Router.extend({

View File

@ -78,21 +78,14 @@
<!-- user profile -->
<script type="text/html" id="tmpl-user-profile">
<form class="form-horizontal">
<fieldset>
</fieldset>
</form>
<dl class="dl-horizontal">
</dl>
</script>
<script type="text/html" id="tmpl-user-profile-element">
<div class="control-group">
<label class="control-label"><%= key %></label>
<div class="controls">
<div><%= value %></div>
</div>
</div>
<dt><%= key %></dt>
<dd><%= value %></dd>
</script>