From e2e2dfca435f0d583ced41ca6f8a025e7ff48e46 Mon Sep 17 00:00:00 2001 From: Michael Jett Date: Thu, 3 May 2012 18:00:50 -0400 Subject: [PATCH] TD now rendered dynamically --- .../src/main/webapp/resources/js/app.js | 34 +++++++++++++------ .../webapp/resources/template/client.html | 8 ++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/openid-connect-server/src/main/webapp/resources/js/app.js b/openid-connect-server/src/main/webapp/resources/js/app.js index 02e7797fe..a9abff065 100644 --- a/openid-connect-server/src/main/webapp/resources/js/app.js +++ b/openid-connect-server/src/main/webapp/resources/js/app.js @@ -25,18 +25,20 @@ var ClientView = Backbone.View.extend({ + tagName: 'tr', initialize:function () { - this.template = _.template($('#tmpl-client').html()); + if (!this.template) { + this.template = _.template($('#tmpl-client').html()); + } + this.model.bind('change', this.render, this); //this.model.on('change', this.render) }, render:function (eventName) { - - $(this.el).append(this.template(this.model.toJSON())); - + this.$el.html(this.template(this.model.toJSON())); return this; }, @@ -59,20 +61,30 @@ } }); + var ClientListView = Backbone.View.extend({ + + el: $("#client-table"), + + addOne: function(todo) { + + var view = new ClientView({ + model:new ClientModel() + }); + + var chilly = view.render().el; + this.$('tbody').append(view.render().el); + + view.model.set({name:'hello world'}); + } + }); + $(function () { // load templates and append them to the body - $.get('resources/template/client.html', function (templates) { $('body').append(templates); - var view = new ClientView({ - el:$('#client-table tbody'), - model:new ClientModel() - }); - - view.model.set({name:'hello world'}); }); diff --git a/openid-connect-server/src/main/webapp/resources/template/client.html b/openid-connect-server/src/main/webapp/resources/template/client.html index 003fa50d1..d9037251d 100644 --- a/openid-connect-server/src/main/webapp/resources/template/client.html +++ b/openid-connect-server/src/main/webapp/resources/template/client.html @@ -1,5 +1,5 @@ \ No newline at end of file