I have a function setServiceId(serviceId) which is called by clicking on some button and Im passing id of that service.
Also I have serviceIdSubscrier = vm.selectedServiceId.supsendableSubscribe(changeServiceId) that listens on every change of serviceId (for example, if I clicked id = 5151, and then 5152, this event will be triggered and called a function changeServiceId)
However, now, I want when I click multiple times same service, to be also triggered, as it would trigger when id's are different (for example, I clicked for service id=5151, and then again id=5151) and I would like to have same behavior as it I clicked different id's
this is my whole functions:
function setServiceId(serviceId) {
vm.selectedServiceId(serviceId);
jQuery.post(rootUrl + 'spaemployeeadmin/GetFirstSearchFilterDateForParent', {
locationId: vm.selectedLocationId()
})
.done(function (data) {
var dateObj = { day: data.Day, month: data.Month, year: data.Year };
vm.refreshData(dateObj, null);
});
}
serviceIdSubscrier = vm.selectedServiceId.supsendableSubscribe(changeServiceId)
function changeServiceId() {
var currentService = getService();
if (vm.combineSchedules()) {
vm.selectedService(currentService || {});
refreshAllowedTimes().then(function () {
setTimeByPreviousSelection();
checkToPushCriteria();
});
} else {
refreshOnServiceType();
}
}
If serviceId were an object you could change it to another object with the same values and a change would register.
5 === 5 //True
{id: 5} === {id: 5} //False