[Pkg-javascript-commits] [backbone] 20/34: moving edit UI out into a template.
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:58:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.2.0
in repository backbone.
commit 6ea50e6a1e8048afa2fd288fc52f1d6c04af04bf
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Tue Oct 19 17:20:40 2010 -0400
moving edit UI out into a template.
---
examples/todos.html | 5 +++++
examples/todos.js | 19 ++++---------------
2 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/examples/todos.html b/examples/todos.html
index 96d3e2c..c15fb53 100644
--- a/examples/todos.html
+++ b/examples/todos.html
@@ -18,6 +18,11 @@
<span class="todo-content"><%= model.get('content') %></span>
</script>
+ <script id="edit-template" type="x-ejs">
+ <input type="text" value="<%= model.get('content') %>" />
+ <input type="submit" class="update" value="Update" />
+ </script>
+
<script src="todos.js"></script>
</head>
<body>
diff --git a/examples/todos.js b/examples/todos.js
index 16abee8..8794438 100644
--- a/examples/todos.js
+++ b/examples/todos.js
@@ -23,7 +23,8 @@
className: "todo",
- template: _.template($('#todo-template').html()),
+ displayTemplate: _.template($('#todo-template').html()),
+ editTemplate: _.template($('#edit-template').html()),
events: {
"dblclick span": "edit",
@@ -40,7 +41,7 @@
// Render (or empty and re-render) this view. If this task is complete,
// make the text have strike through.
render: function () {
- $(this.el).html(this.template({model: this.model}));
+ $(this.el).html(this.displayTemplate({model: this.model}));
this.setComplete();
return this;
},
@@ -53,19 +54,7 @@
// to edit this task's content and a submit button to click to save the
// updates.
edit: function () {
- var input = this.$(this.make("input", {
- type: "text",
- value: this.$(this.el).text()
- }));
- var submit = this.$(this.make("input", {
- type: "submit",
- className: "update",
- value: "Update"
- }));
- this.$(this.el)
- .empty()
- .append(input)
- .append(submit);
+ $(this.el).html(this.editTemplate({model : this.model}));
},
// Switch back to display mode after being in edit mode. Save the new
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list