From 5d7fb696a5ef9e69212fa2fc5df5b21cf696123f Mon Sep 17 00:00:00 2001 From: Pindi Albert Date: Sat, 26 May 2012 15:00:17 -0700 Subject: [PATCH 1/2] Add 'show' event when an object is added to a container --- agility.js | 1 + docs/_docs.md | 1 + test/public/core.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/agility.js b/agility.js index 6ec474d..304e645 100644 --- a/agility.js +++ b/agility.js @@ -194,6 +194,7 @@ } this._container.children[obj._id] = obj; // children is *not* an array; this is for simpler lookups by global object id this.trigger(method, [obj, selector]); + obj.trigger('show'); // Dispatch show event to object // ensures object is removed from container when destroyed: obj.bind('destroy', function(event, id){ self._container.remove(id); diff --git a/docs/_docs.md b/docs/_docs.md index 39e37b9..8bf9bb9 100644 --- a/docs/_docs.md +++ b/docs/_docs.md @@ -276,6 +276,7 @@ Agility events are fired by the object core, as well as Models and plugins. When Presently, the following Agility events are fired: + `create`: Fired upon object creation. ++ `show`: Fired when the object is added to a container. + `destroy`: Fired before object is destroyed. + `add`: Fired when a new Agility object is added to the object's container. + `remove`: Fired with an Agility object is removed from the object's container. diff --git a/test/public/core.js b/test/public/core.js index 18d351d..32941e8 100644 --- a/test/public/core.js +++ b/test/public/core.js @@ -1047,6 +1047,20 @@ ok(o===obj1 && s==='sel', "append() called"); }); + test("`show` container event", function(){ + var showCalled = false; + var obj1 = $$(); + var obj2 = $$({ + controller: { + show: function(){ + showCalled = true; + } + } + }); + obj1.append(obj2); + ok(showCalled, "show() called"); + }); + test("Model events", function(){ var t = false; var obj = $$({}, {}, { From 459a9837bae6e6c8fee5ef643ffd219b3de2ce7c Mon Sep 17 00:00:00 2001 From: Pindi Albert Date: Wed, 27 Jun 2012 14:30:53 -0700 Subject: [PATCH 2/2] Run "make docs" --- docs/docs.html | 2 ++ docs/gallery.html | 1 + index.html | 1 + 3 files changed, 4 insertions(+) diff --git a/docs/docs.html b/docs/docs.html index 9f595ad..6b4d04d 100644 --- a/docs/docs.html +++ b/docs/docs.html @@ -352,6 +352,7 @@

Agility events

Presently, the following Agility events are fired: