user profile display improvements
parent
f8e82037fe
commit
485e17c893
|
@ -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({
|
||||
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue