I have a table with rows. Each time I click a row, the viewmodel notifies it to other viewmodels by using a subscriber.
At the same time, I have icons on each row. Whenever I click on an icon I have a click
binding to a function in one of my viewmodels.
Now, the problem arises when I try to get any value from the row in the click
binded function.
It seems the subscription gets fired later than the click function. Therefore when I'm on the click function I can not access the data from the row yet.
I solved it by padding the row data
directly in the click function. But then I want to be able to access the click function from outside the row, lets say, in a fixed or absolute element in my DOM, and therefore I won't be able to pass the row
data from its click
binding. That's why I'm using a subscriber that gets fired on row select.
My question is. How do we know when the subscriber is going to be fired? Is there any way to change the order?
self.sendDataAndClick = function(data){
self.setData(data);
self.showAddModal();
};
//gets the info from the orders vm
shouter.subscribe(function(data) {
self.setData(data);
}, this, "selectedOrder");
//sets the data for the viewmodel
self.setData = function(data){
self.equipmentNumber(data.equipment_id());
self.leg(data);
self.setSeals(data);
}