Client backbone.js Model initial commit

pull/59/head
Michael Jett 2012-04-24 16:37:25 -04:00
parent 181b0ce605
commit d1a773d512
2 changed files with 73 additions and 2 deletions

View File

@ -3,6 +3,8 @@
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="resources/boostrap2/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<script src="resources/js/app.js"></script>
<script src="resources/js/tmpl.js"></script>

View File

@ -10,8 +10,77 @@ $(function () {
refreshTokens:false
};
console.log(tmpl('client_tmpl',ExampleOpenIdClient));
console.log(tmpl('client_tmpl', ExampleOpenIdClient));
$('#client-table').append(tmpl('client_tmpl',ExampleOpenIdClient));
$('#client-table').append(tmpl('client_tmpl', ExampleOpenIdClient));
});
var Client = Backbone.Model.extend({
// We can pass it default values.
defaults:{
name:null,
redirectURL:"http://myURL.domain",
grantType:["my grant type 1", "my grant type 2"],
scope:["scope 1", "scope 2"],
authority:"my authority",
description:"my description",
refreshTokens:false
},
urlRoot:"../api/clients"
});
var ClientCollection = Backbone.Collection.extend({
model:Client,
url:"../api/clients"
});
var ClientView = Backbone.View.extend({
initialize:function () {
var self = this;
if (!($.isFunction(self.template))) {
$.get('resources/template/client.html', function (templates) {
$('body').append(templates);
self.template = $('#tmpl-client').template();
});
}
this.model.bind("change", this.render, this);
},
render:function (eventName) {
$(this.el).html(this.template(this.model.toJSON()));
return this;
},
events:{
"change input":"change",
"click .save":"saveClient",
"click .delete":"deleteClient"
},
change:function (event) {
},
saveClient:function () {
},
deleteClient:function () {
},
close:function () {
$(this.el).unbind();
$(this.el).empty();
}
});