Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda