user profile display improvements
parent
f8e82037fe
commit
485e17c893
|
@ -317,6 +317,9 @@ var UserProfileView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function() {
|
initialize:function() {
|
||||||
|
if (!this.template) {
|
||||||
|
this.template = _.template($('#tmpl-user-profile-element').html());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function() {
|
render:function() {
|
||||||
|
@ -324,34 +327,17 @@ var UserProfileView = Backbone.View.extend({
|
||||||
$(this.el).html($('#tmpl-user-profile').html());
|
$(this.el).html($('#tmpl-user-profile').html());
|
||||||
|
|
||||||
_.each(this.model, function (value, key) {
|
_.each(this.model, function (value, key) {
|
||||||
$("fieldset",this.el).append(
|
if (key && value) {
|
||||||
new UserProfileElementView({
|
$('dl', this.el).append(
|
||||||
model:{key: key, value: value}
|
this.template({key: key, value: value})
|
||||||
}).render().el);
|
);
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
return 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
|
// Router
|
||||||
var AppRouter = Backbone.Router.extend({
|
var AppRouter = Backbone.Router.extend({
|
||||||
|
|
||||||
|
|
|
@ -78,21 +78,14 @@
|
||||||
<!-- user profile -->
|
<!-- user profile -->
|
||||||
<script type="text/html" id="tmpl-user-profile">
|
<script type="text/html" id="tmpl-user-profile">
|
||||||
|
|
||||||
<form class="form-horizontal">
|
<dl class="dl-horizontal">
|
||||||
<fieldset>
|
</dl>
|
||||||
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="tmpl-user-profile-element">
|
<script type="text/html" id="tmpl-user-profile-element">
|
||||||
|
|
||||||
<div class="control-group">
|
<dt><%= key %></dt>
|
||||||
<label class="control-label"><%= key %></label>
|
<dd><%= value %></dd>
|
||||||
<div class="controls">
|
|
||||||
<div><%= value %></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue