Button to add more servers

This commit is contained in:
Björn Dahlgren 2014-06-05 00:29:31 +02:00
parent 9d55eb6162
commit 957e665ff2
3 changed files with 12 additions and 10 deletions

View File

@ -6,24 +6,14 @@ define(function (require) {
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
AddServerView = require('app/views/servers/add'),
tpl = require('text!tpl/servers/empty.html');
return Marionette.ItemView.extend({
template: _.template(tpl),
events: {
"click #add-server": "addServer"
},
initialize: function (options) {
this.servers = options.servers;
},
addServer: function () {
var view = new AddServerView({servers: this.servers});
new Backbone.BootstrapModal({ content: view, servers: this.servers }).open()
},
});
});

View File

@ -6,6 +6,7 @@ define(function (require) {
_ = require('underscore'),
Backbone = require('backbone'),
Marionette = require('marionette'),
AddServerView = require('app/views/servers/add'),
EmptyView = require('app/views/servers/empty'),
ListItemView = require('app/views/servers/list_item'),
tpl = require('text!tpl/servers/list.html'),
@ -19,6 +20,10 @@ define(function (require) {
emptyView: EmptyView,
events: {
"click #add-server": "addServer"
},
buildItemView: function(item, ItemViewType, itemViewOptions){
// build the final list of options for the item view type
var options = _.extend({model: item}, itemViewOptions);
@ -32,5 +37,10 @@ define(function (require) {
// return it
return view;
},
addServer: function () {
var view = new AddServerView({servers: this.collection});
new Backbone.BootstrapModal({ content: view, servers: this.collection }).open()
},
});
});

View File

@ -8,3 +8,5 @@
<!-- want to insert collection items, here -->
<tbody></tbody>
</table>
<a class="btn btn-primary" id="add-server" href="#">Add new server</a>