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

290
Views
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
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!