jadrake75 / ng-scrolling-table

MIT License
8 stars 2 forks source link

selection event should send tableId #74

Open jadrake75 opened 10 years ago

jadrake75 commented 10 years ago

The selection event is only sending the { selected: [Array of Ids]} and it should also send the tableID in case there are multiple tables on a page.

Xanir commented 10 years ago

Sending the table id for multiple tables means the controller needs to know the ID set on the table. This seems really awkward.

jadrake75 commented 10 years ago

Actually this is to ensure the originator of the event is known. Lets say you have two tables managed by the same controller. JS is not strongly typed so you can't look at the data of the selected to drive the originator. It is good practice for events to always dispatch the data (or references) to what is changing (ie. the selected) and "where" it is selected from. It is up to the listener to decide if it cares to take some action from it. Since the selection event is not specific (could come from anywhere in the root scope hierarchy) the listener should know which source originated the event, so that it can decide whether to continue to take action on the items. Most UI frameworks (including JS do this with events. For example "target" or "source" of the UI Event object).