Is there a way to set a cookie in order to remember an open tab? The tabs in question are generated using Coldfusion and Javascript

Trying to figure this out, but currently stuck. I have tabbed sections generated in Coldfusion. The selected section is marked by a class named "tab_selected (+ the UUID created in coldfusion)", while unselected tabs have class names with "tab_unselected (+ the UUID created in coldfusion)". When you click on an unselected tab, it changes to "tab_selected (+ the UUID)" and adjusts the rest accordingly.

The goal is to use javascript to find the element with the "tab_selected" class when leaving the page, then set a cookie with that element's ID...

My attempted solution so far (using JQuery) may be totally off base. Seeking guidance.

$(window).unload( function () {
$("selector[name*='tab_selected_text']").cookie("TABS_REMEMBER", 1, { expires: null });
});

Answer №1

With the utilization of jquery along with its cookie plugin, setting up tab functionality becomes effortless and seamless.

When defining your tabs, ensure to incorporate the following script:

<script type="text/javascript">
  $(function () {
    $("#tabs").tabs({
      cookie: {
        // set cookie to last for a day, otherwise it will be session-based
        expires: 1
      }
    });
  });
</script>

This will allow the tabs component to remember the previously used tab.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adjusting the size of DIVs according to images retrieved dynamically from a database

I am currently in the process of building my online portfolio, and while I am new to JQuery and PHP, I am working through any challenges that come my way. However, I am facing a roadblock that has left me puzzled. My goal is to create a seamless iframe to ...

Using Three.js to rotate a sphere (globe) to a different location (city) on the sphere's surface

Currently, I am in the process of creating a spherical globe with predefined locations that are geo-mapped and represented as points. My goal is to highlight these locations by smoothly rotating the globe along its y-axis from one point to another. Despite ...

Display the value in Vue.js as a price format while maintaining it as an integer

I have created a Vue component called "formatted-number" which takes in an integer value (e.g. 1234) and currently displays it as a string (e.g. "12.34") to represent a price in a textfield, with the appropriate "," or "." based on the country. However, I ...

What are the best options for storing small data in a React or Next.js project?

As I work on my personal portfolio using Next.JS, I've come to a point where I need to display multiple projects each with their own set of information like images, titles, and links. I'm wondering where would be the best place to store this data ...

Display the JSON data by pressing Enter key instead of clicking on the submit button

I am facing an issue with my MVC view where clicking the submit button posts data using Ajax to the Controller. The controller returns a JSON result containing messages which are then displayed on the View. The problem arises when I press Enter after seein ...

The return value of fs.mkdirSync is undefined

I'm facing a challenge with creating a directory and utilizing that directory as a variable to extract files from zip/rar files. The section of code that is causing an error is shown below: var fileZip = fileName.replace(/^.*[\\\/]/, ...

Content that is dynamically generated by a database

I have been working on creating a unique wall feature for my website, inspired by Facebook. My aim is to allow users to submit form data and have it validated before storing it in a database. Additionally, I want this stored data to be displayed in a desig ...

Is there a way to efficiently return an array of object and nested object keys with their full paths through recursion

My grasp of JS is still in its early stages, so understanding how the stack and recursion function can be challenging for me at this point. The task at hand involves displaying an array of object keys, including the parent object name if the object is nest ...

Encountered an error trying to access an array element by index stored in a variable within Vue.JS,

It appears that I have encountered a bug in my code. My intention is to retrieve components objects by index (for the tag), but I am facing an unusual issue. Details of the problem can be seen below: Successful scenario: let steps = ['Handler' ...

What is preventing me from extracting the callback function from the app.get method in Node.js and Express?

In my server.js file, I'm attempting to do the following: // This code is not functioning as expected, and I am unsure why. var findBooks = function (err, books) { if (!err) { return response.send(books); } else { console.log( ...

Stop the upload progress in Angular 6 by unsubscribing from the upload observable, without halting the actual

When attempting to cancel an upload by unsubscribing, the unsubscribe action only stops the progress of the upload from being displayed, but the actual upload process continues and files are still uploaded to the server. This issue is present in the upload ...

Arrange a div close to another div with the help of absolute positioning

My goal is to create a tooltip-like positioning for an element within the same container as another element. When clicked, this particular element will display a div containing a table. You can find the complete code here: http://jsbin.com/xihebol When s ...

Converting JSON data to HTML using Handlebars

Can you assist me in transforming the following JSON data into a table with 3 columns: property name, property source, and property value? "result": { "total": 100, "config": { "propName1": { "source": "propsrc1", ...

Searching for users with specific patterns of string using LDAP JS in Node JS

Currently, I have implemented LDAP JS for Authentication in my Angular JS application and everything is working smoothly. Now, as I am creating a new view, I have a specific requirement: There is a text box where an admin will input a few letters of a u ...

Unlocking JSON Keys Using Dashes

When working with JSON objects, we typically access elements using dot notation. For example, var obj = {"key": "value"}; var val = obj.key;. However, what if the key contains hyphens, like in this case: var obj = {"key-with-hyphens": "value"};? Do we ne ...

React - Uncaught Error: e.preventDefault is not a function due to Type Error

Encountering an issue with Axios post and react-hook-form: Unhandled Rejection (TypeError): e.preventDefault is not a function The error arises after adding onSubmit={handleSubmit(handleSubmitAxios)} to my <form>. Seeking to utilize react-hook-form ...

why is my angular listing malfunctioning when I try to compare two fields?

<div ng-controller="SamsungServicesCtrl"> <ion-content> <li class="item item-checkbox" ng-repeat="item in items" > <img src="{{item.icon}}" style="float:left;height:30px;width:30px;padding-right:5px;" & ...

"Uncovering a memory leakage issue within a recursive polling function in JavaScript

Current issue in need of resolution: My team and I are currently working on a large application that was initially released around two years ago. We are in the process of adding a new "always-on" status screen to the application, which will be the default ...

The desired jQuery datatable theme did not take effect on the JSP page

Experimenting with various JQuery themes and controls. Attempting to use a datatable example and apply the default theme provided here. However, I have been encountering difficulties. Seeking assistance to understand the root cause of this issue. Also, in ...

Encountering an SSL error while trying to establish a connection between a local server and the Heroku PostgreSQL

Currently, I am facing an issue with connecting to my postgreSQL database on Heroku from my express app. The connection functions properly when the express app is deployed on Heroku, but I encounter difficulties connecting to the database while running the ...