[Pkg-javascript-commits] [backbone] 70/101: axed setMode. setCallbacks -> bindCallbacks
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:58:30 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.1.0
in repository backbone.
commit 21dfb55072190ffdf9fd3239a51593f963e5ce0b
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Tue Oct 12 15:41:42 2010 -0400
axed setMode. setCallbacks -> bindCallbacks
---
backbone.js | 13 +------------
docs/backbone.html | 2 +-
index.html | 24 +++++++++++++++++++-----
test/view.js | 15 ---------------
4 files changed, 21 insertions(+), 33 deletions(-)
diff --git a/backbone.js b/backbone.js
index d059685..098c5fd 100644
--- a/backbone.js
+++ b/backbone.js
@@ -537,17 +537,6 @@
return el;
},
- // Makes the view enter a mode. Modes have both a 'mode' and a 'group',
- // and are mutually exclusive with any other modes in the same group.
- // Setting will update the view's modes hash, as well as set an HTML class
- // of *[mode]_[group]* on the view's element. Convenient way to swap styles
- // and behavior.
- setMode : function(mode, group) {
- if (this.modes[group] === mode) return;
- $(this.el).setMode(mode, group);
- this.modes[group] = mode;
- },
-
// Set callbacks, where this.callbacks is a hash of
//
// *{selector.event_name: callback_name}*
@@ -562,7 +551,7 @@
// Passing a selector of `el` binds to the view's root element.
// Change events are not delegated through the view because IE does not
// bubble change events at all.
- setCallbacks : function(callbacks) {
+ bindCallbacks : function(callbacks) {
$(this.el).unbind();
if (!(callbacks || (callbacks = this.callbacks))) return this;
for (key in callbacks) {
diff --git a/docs/backbone.html b/docs/backbone.html
index b5bd55e..3457236 100644
--- a/docs/backbone.html
+++ b/docs/backbone.html
@@ -364,7 +364,7 @@ and behavior.</p> </td> <td class="code">
Uses jQuery event delegation for efficiency.
Passing a selector of <code>el</code> binds to the view's root element.
Change events are not delegated through the view because IE does not
-bubble change events at all.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">setCallbacks</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">callbacks</span><span class="p">)</span> <span class="p">{</span>
+bubble change events at all.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">bindCallbacks</span> <span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">callbacks</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">el</span><span class="p">).</span><span class="nx">unbind</span><span class="p">();</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="p">(</span><span class="nx">callbacks</span> <span class="o">||</span> <span class="p">(</span><span class="nx">callbacks</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">callbacks</span><span class="p">)))</span> <span class="k">return</span> <span class="k">this</span><span class="p">;</span>
<span class="k">for</span> <span class="p">(</span><span class="nx">key</span> <span class="k">in</span> <span class="nx">callbacks</span><span class="p">)</span> <span class="p">{</span>
diff --git a/index.html b/index.html
index faf6ef4..d07d75a 100644
--- a/index.html
+++ b/index.html
@@ -197,8 +197,7 @@
<li>– <a href="View-jQuery">$ (jQuery)</a></li>
<li>– <a href="View-render">render</a></li>
<li>– <a href="View-make">make</a></li>
- <li>– <a href="View-setMode">setMode</a></li>
- <li>– <a href="View-setCallbacks">setCallbacks</a></li>
+ <li>– <a href="View-bindCallbacks">bindCallbacks</a></li>
</ul>
</div>
@@ -915,13 +914,14 @@ ui.Chapter = Backbone.View.extend({
function with your code that renders the view template from model data,
and updates <tt>this.el</tt> with the new HTML. You can use any flavor of
JavaScript templating or DOM-building you prefer. Because <b>Underscore.js</b>
- is already on the page, <tt>_.template</tt> is available. The convention is to
- <tt>return this</tt> at the end of <b>render</b> to enable chaining.
+ is already on the page, <tt>_.template</tt> is already available. A good
+ convention is to <tt>return this</tt> at the end of <b>render</b> to
+ enable chained calls.
</p>
<pre>
ui.Chapter = Backbone.View.extend({
- render : function() {
+ render: function() {
var data = this.model.attributes();
$(this.el).html(this.template.render(data));
return this;
@@ -929,6 +929,20 @@ ui.Chapter = Backbone.View.extend({
});
</pre>
+ <p id="View-make">
+ <b class="header">make</b><code>view.make(tagName, [attributes], [content])</code>
+ <br />
+ Convenience function for creating a DOM element of the given type (<b>tagName</b>),
+ with optional attributes and HTML content. Used internally to create the
+ initial <tt>view.el</tt>.
+ </p>
+
+
+
+
+
+
+
<h2 id="changes">Change Log</h2>
diff --git a/test/view.js b/test/view.js
index aba3c93..85ef36f 100644
--- a/test/view.js
+++ b/test/view.js
@@ -1,18 +1,3 @@
$(document).ready(function() {
module("Backbone View");
-
- var View = Backbone.View.extend({
- className : "view",
- render : function(){
- $('body').append(this.el);
- }
- });
-
- var view = new View();
- view.render();
-
- test("view: setMode", function(){
- view.setMode("active", "test");
- ok(view.el.hasClass("active_test"), "View should set modes");
- });
});
\ No newline at end of file
--
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