I may have found a bug of conception in this PureMVC javascript port :
I found it by following one specific action in the EmployeeAdmin sample.
In the ApplicationFacade.startup method, the app object is given : it is the Dom node of id="application" with 3 properties : application.userForm, application.userList and application.rolePanel. I followed the rolePanel component.
application.rolePanel is the Dom node of id="roleListPanel".
I followed the reference into the PureMVC code, and found it finally used in the RolePanelMediator (that seems logic).
The problème is, in RolePanelMediator, an eventListener is binded like this :
rolePanel.addEventListener( RolePanel.ADD, Relegate.create(this,this._onAddRole) );
Where rolePanel is the Dom node of id="roleListPanel". This action does nothing to me : you add an eventListener on a "div" Dom node. The equivalent action is in fact done in the RolePanel view component by :
document.getElementById('addRoleButton').onclick = Relegate.create(this,this.__onAdd);
Which is not the right place in the PureMVC philosophy to bind event listeners.
Unless I am totally wrong, there is a problem somewhere.
I think there is 2 solutions : 1) removing the Mediator role for binding event listeners, and every unused arguments (starting with argument app in ApplicationFacade.startup). 2) removing the bindings in views components and finding a solution to keep the Mediator role.
The 2nd solution follows PureMVC philosophy but seems harder to proceed.
I hope that I'm right, and that this post will be useful !
|