Fixed dynamically-loading side menu to show available plugins.

This commit is contained in:
Jeff Cross
2011-11-21 23:05:30 -07:00
parent 4a99930b42
commit 757618c830
5 changed files with 10 additions and 12 deletions

View File

@@ -34,8 +34,6 @@
<div class="row">
<div id="menu" class="three columns">
<div class="panel">
<h5>App Config</h5>
<hr />
<h5>Plugins</h5>
<div class="links">
<em>No Plugins Loaded</em>
@@ -262,17 +260,11 @@
</script>
<script id="app-nav-template" type="html/template">
<li><a href="#/">Config</a></li>
<li><a href="#/plugins">Plugins</a>
<ul>
<% _.each(plugins.models, function (plugin) { %>
<li><a href="#/plugins/<%= plugin.attributes._id %>"><%= plugin.attributes.name %></a></li>
<li><a href="#/plugins/<%= plugin.attributes.name %>"><%= plugin.attributes.name %></a></li>
<% }); %>
</ul>
</li>
<li>
<a>Reference</a>
</li>
</script>
<script id="model-detail-template" type="html/template">
<div><%= name %></div>

View File

@@ -5,6 +5,10 @@ var Router = Backbone.Router.extend({
// allows to send restful calls over AJAX
Backbone.emulateHTTP = true;
window.app = new App();
window.appNavView = new AppNavView({
model: app,
el: $("#menu .links")
});
app.fetch({
success: function (model, response) {

View File

@@ -1,10 +1,12 @@
window.AppNavView = Backbone.View.extend({
template: _.template($("#app-nav-template").html()),
initialize: function () {
this.model.bind("change", this.render, this);
},
render: function(type, model) {
$(this.el).html(this.template(this.model.toJSON()));
// $(this.el).html(JSON.stringify(this.model.get("plugins").toJSON()));
return this;
}

View File

@@ -5,6 +5,7 @@ window.PluginView = Backbone.View.extend({
render: function () {
var _self = this;
$(this.el).empty();
this.model.get("objects").each(function(obj){
if (obj.get("description")) {
//TODO: Plug this in to a view/model/template

View File

@@ -43,7 +43,6 @@ window.SchemaView = Backbone.View.extend({
this.render();
},
addNewProperty: function (e) {
console.log("addNewProperty()");
$("form", this.el).append(_.template($("#new-schema-property-template").html(),{key: '', type: ''}));
},
render: function () {