Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'show' event when an object is added to a container #84

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions agility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions docs/_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ <h3><a href="#events-agility">Agility events</a></h3>
<p>Presently, the following Agility events are fired:</p>
<ul>
<li><code>create</code>: Fired upon object creation.</li>
<li><code>show</code>: Fired when the object is added to a container.</li>
<li><code>destroy</code>: Fired before object is destroyed.</li>
<li><code>add</code>: Fired when a new Agility object is added to the object's container.</li>
<li><code>remove</code>: Fired with an Agility object is removed from the object's container.</li>
Expand Down Expand Up @@ -947,6 +948,7 @@ <h3><a href="#persist-restful">$$.adapter.restful</a></h3>
api/resource/123
</pre></div>


</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions docs/gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ <h2><a href="http://thewall.agilityjs.com">The Wall</a></h2>
<h3>User submissions</h3>
<p>Have you created an awesome project that showcases Agility's capabilities? <a href="https://github.com/arturadib/agility/tree/gh-pages">Fork this site</a>, add a brief description of your project, and send a pull request. We'd love to see what you can do with Agility!</p>


</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ <h3>The infamous To-Do example</h3>

<p><div class="demo"></div></p>


</div>
</div>

Expand Down
14 changes: 14 additions & 0 deletions test/public/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $$({}, {}, {
Expand Down