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

291
Visualizações
Remove session params if dropdown value changed

Is it possible to delete session[:sth] using jQuery/Javascript ?

In the Rails controller I set the session parameters:

  def new
    #other logic (...)

    session[:patient_id_to_add_caregiver] = params[:patient_to_caregiver]
  end

Below I've got simple function to handle case when the user selects one field from dropdown list, search field and search results should be hidden:

registrants.js

  function toggle_caregiver_fields_on_ready(){
    var caregiverSectionElement = $("#registrant_registration_attributes_registrant_id");
    if ($("#registrant_registration_attributes_registered_as").val() === 'caregiver') {
      $('.patient-caregiver-section').removeClass('hidden');
      $('#patient-search-results').removeClass('hidden');
    } else {       
        $('.patient-caregiver-section').addClass('hidden');
        $('#patient-search-results').addClass('hidden');
      }
  }

In the same JS function I want to clear session[:patient_id_to_add_caregiver] when (#registrant_registration_attributes_registered_as").val() === 'caregiver'). I've tried with sessionStorage.clear(); to be:

if ($("#registrant_registration_attributes_registered_as").val() === 'caregiver') {
  sessionStorage.clear();
  $('.patient-caregiver-section').removeClass('hidden');

(...)

But nothing happened. Is it possible to clear this session storage?

about 4 years ago · Juan Pablo Isaza
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