Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
How to suspend and unsuspend property in order to work as expected in knockout.js

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();
    }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!