-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dave McLain
committed
Oct 12, 2011
1 parent
f405782
commit bdd720a
Showing
3 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
armstrong/core/arm_wells/static/arm_wells/js/well-node-inline.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
window.Node = Backbone.Model.extend({ | ||
url: "", | ||
}); | ||
|
||
window.NodeList = Backbone.Collection.extend({ | ||
url: "", | ||
model: window.Node | ||
}); | ||
|
||
window.NodeListItemView = Backbone.View.extend({ | ||
tagName: "div", | ||
render: function() { | ||
var html = this.options.template(this.model.toJSON()); | ||
django.jQuery(this.el).html(html); | ||
return this; | ||
} | ||
}); | ||
|
||
window.NodeListView = Backbone.View.extend({ | ||
tagName: "div", | ||
render: function() { | ||
return this; | ||
}, | ||
addOne: function(node) { | ||
var view = new window.NodeListItemView({ | ||
model: node, | ||
prefix: this.options.prefix, | ||
template: _.template(django.jQuery('#nodes-list-item-template').html()), | ||
}); | ||
alert(this.options.target_id); | ||
django.jQuery(this.options.target_id).append(view.render().el); | ||
}, | ||
addAll: function() { | ||
for(i=0; i<this.collection.length; i++){ | ||
this.addOne(this.collection.at(i)); | ||
} | ||
} | ||
}); |
28 changes: 28 additions & 0 deletions
28
armstrong/core/arm_wells/templates/arm_wells/admin/well-node-inline.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'admin/edit_inline/backbone.html' %} | ||
|
||
{% block templates %} | ||
<script type="text/template" id="{{ prefix }}-list-item-template"> | ||
<li class="item"> | ||
<span class="content"><%= content_id %></span> | ||
<h4>Rendering</h4> | ||
<button class="delete">Delete</button | ||
</li> | ||
</script> | ||
<script> | ||
(function($) { | ||
$(document).ready(function($) { | ||
var collection = new window.NodeList(); | ||
collection.add(new Node({content_id: 4})); | ||
collection.add(new Node({content_id: 6})); | ||
collection.add(new Node({content_id: 7})); | ||
collection.add(new Node({content_id: 3})); | ||
window.App = new window.NodeListView({ | ||
prefix: '{{ prefix }}', | ||
collection: collection, | ||
target_id: '#{{ prefix }}-collection' | ||
}); | ||
window.App.addAll(); | ||
}); | ||
})(django.jQuery); | ||
</script> | ||
{% endblock %} |