Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:18:51+00:00 2026-06-17T04:18:51+00:00

In my nav-list, I have a drop box selection that contains all users, exclusively

  • 0

In my nav-list, I have a drop box selection that contains all users, exclusively available to an administrator. The administrator can select a user, and the view is updated via ajax to display the selected user’s information.

The view is updated with something like this:

$(#Users).change(function() {
    $ajax({
        ... yada yada update information in view.

However, what I want to implement is if I change to another view/url (Such as my account html.erb to a mygraph.html.erb) or refresh my page, I want the user drop box selection to persist with the user selection I made.

I thought of using rails cookies to do this. But I must redirect to controller to set the cookie.

I attempted a POST ajax call,

$(#Users).change(function() {
  $.ajax({
    ...
    data: {
       "<%= cookies[:selected] %>": this.value

It doesn’t work, but for some reason, I already doubted that it would be that simple.

How should I implement this solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:18:52+00:00Added an answer on June 17, 2026 at 4:18 am

    You don’t have to redirect_to controller action. You can make ajax call to controller action. You can set cookie in controller action as follow:

     $(function(){
       $('#user_select')change(function(){
         value = $(this).val()
         $.post("controller/action",{selected_value : value}, function(data, status){
           if(status == "success")
           {
             alert(data);
           } 
        });
       return false;
       })
      })
    

    Controller:

     def action
       cookies[:name]=params[:selected_value]
       render :text => "success"
     end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nav bar with a drop down that is working beautifully. The
I have a 2-level drop down menu that looks great in all browsers. Now
i have 4 menu drop down list that i bind a click that calls
I have a horizontal nav bar that is an unordered list with anchor tags.
I want to have my list (nav) align to the center of an image
I have a horizontal list (for a nav bar) and i want an individual
I have built a nav where I have an unordered list made up of
how can i centre the list items in the nav bar, list items are
I have this function for adding options to a Select list: function addOption(selectbox, value,
I have a list that I'd like the main elements to align vertically and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.