nathanvda/cocoon — Issue #32: callback questions
Author: ruckus-matte
Created: 2011-12-16 00:04:29+00:00
State: open

I have some questions about callbacks in the cocoon.js. Everything here is in relation to the specific file from v1.0.15.

**Question 1 - Why are the callbacks called on the parents of the add/remove links?**

What about a situation, like mine, where the triggering add_association link does not live inside the html block that receives the new html? I have a toolbar containing my add link and the insertion node is in a separate container. The parent node of the add link, the toolbar, doesn't have, or need, a convenient id or class to build the selector that my jquery trigger-watching code can use. Was there a particular reason you didn't just trigger the callback off the add_link? thus line 50 goes from ...

````javascript
$this.parent().trigger('insertion-callback');
````

to

````javascript
$this.trigger('insertion-callback');
````

and you don't need a separate function for trigger_removal_callback. you can just use the following at lines 55 and 62.

````javascript
$this.trigger('removal-callback');
`````

much easier, imho. and easier for the developer to hang their trigger-watching functions off of.

**Question 2 - Were lines 20 and 21 setting up insertionCallback and removalCallback variables forgotten about?**

they aren't used but I could see you thinking of providing the developer another spot where you can configure something. I think it's easy enough to watch for the callbacks via jquery though.

(e)