In fact, you want to know if the event is fired by the user or the program , and it is obvious that the event will be triggered during initialization.
The knockout approach of adding a subscription will not help in all cases why, because in most models it will be implemented as
- run the model with undefined data, just structure
(actual KO initilization) - update the model with the source data
(logical init like load JSON , get data etc) - User interaction and updates
The actual step that we want to capture is the change in 3, but in the second step the subscription will get the call. Thus, the best way is to add events to the change, for example
<select data-bind="value: level, event:{ change: $parent.permissionChanged}">
and found an event in the permissionChanged function
this.permissionChanged = function (obj, event) { if (event.originalEvent) {
Sarath Dec 05 '13 at 10:35
source share