JQuery :: Keep Div State After Posting Page And Returning?
Apr 11, 2010
I have a jQuery script which shows a specified div based on the select chosen from the dropdown list.The problem im having is how to retain the div state after the page has been posted and then returned too,
I'm trying to use the cookie plugin to remember the state of a navigation menu from page to page. Here is the snippet of code from towards the top of my page where I am including the jquery files and cookie plugin. The second part of the sample tries to determine whether the cookie exists.
currentSlide is set to 0. vote is set to 2. When I look at my console log, these are true. But in poll_receiveData.php, I'm unable to use a conditional statement with $vote. It's like the program doesn't know how to compare things to $vote. But a SQL statement using $question works just fine. Here's my code:
As an exercise, for the past few days I've been attempting to build a simple search and return data to a page.
The form parses vars to PHP with no refresh PHP gets stuff from the database PHP echos an array Array is output using Jquery in my #result div
Things seem to be working nicely, and the array is indeed coming out the other end.
My next aim was to be able to do something with the output. The first step I assumed would involve printing that array to a table. It's this that I'm having trouble with. I can't figure out the syntax.
With regards to the following code, I think the success function on line 32 and 33 should be something like:
$.each(something something) more something's with TD's and TR's interspersed
The code I have so far is as follows. This successfully echos out the contents of the array, but ultimately isn't useful without being able to access the elements.
My .toggle_container is first time hidden, its good. BUT when I click on the link inside .toggle_container and navigate to another page or when page is load then my .toggle_container become hidden. I want to make it visible/open state. Can you please provide me any solution?
I'm stuck with a simple jquery accordion script that is[URL]..The problem is that there are links inside my divs that brings to another page where the same accordion menu should be included and left opened at the same state like the previous page (hope to be enough clear. The script I'm using will always close all the accordion divs upon the second page load. I'm a total newbie of jquery and couldn't understand exactly how jquery works (among other things I've to do i promise that I will learn jQuery as soon as possible );
I am still experimenting but I have a href which runs a function with a delay of 1 seconds, in that time; jQuery is also playing a 1 second animation. The new page is then loaded successfully. However, when I navigate with the browser Back button, how would I make sure that the initial page is reset to it's inital state as at the moment it appears as it would after the animation (which occurs when the href is clicked) has played.
I am currently working on a page that has a series of <div> tags that .show and .hide whencorrespondinglinks are clicked, the first <div> is visible when you load the page. When you leave the page and return to it, the page reloads and the the first <div> is visible. Is there any way for the browser to save the current <div> that is visible to stay visible when you return to the page?example of what I am trying to accomplish:I load a page and click on the third link to show the third <div> and then after leaving and returning to the page (by clicking the browsers back button) the third <div> is still visible, rather than returning to the original state of the page where the first <div> is visible.
What coding would I use to post some data when the page is loaded rather than posting through clicking a button or link? I've searched around but I can't find it...
I have a page where a user can progressively download more thumbnail images. New thumbnails are loaded using '$.get' followed by an 'append' to the main thumbnail container. If a user clicks on a thumbnail then they link to another page to see the full size image. If the user then presses the back button, the page of thumbnails has returned to its initial state. I was hoping that all the additionally downloaded thumbnails would remain in memory! Is there a way around this? Keeping track of any additional thumbnails that have been downloaded when navigating the to the full size image page and then re-loading them when the user returns to the thumbnails page is not really an option as I don't want the user having to wait for this. This is what facebook appears to do after one has loaded lots of additional items on their news feed - if one links to another page and hits the back button, my suspicion is that all the items are re-loaded - they're not just re-displayed from memory.
I am attempting to make a menu that has a background image that changeswhen you rollover or click a menuitem. I've got the hover effect working fine with CSS, but am trying to implement the click event via jquery with the following:
My process is to reset the entire menu to the inactive state, then switch on the active state for the item that was clicked. Eventually, the item that was clicked will display its corresponding body section as well. I've tried using the CSS pseudo-class "active", but since the entire div is the link, that is unavailable. I've also tried multiple variations of addClass/removeClass, toggleClass, and setAttribute/removeAttributebut nothing hasworked so far.
To say I'm new to JavaScript is a bit of an understatement so bear with me. I have a site set up with a variety of layers of toggles. When you enter the site all of the items are collapsed and you click the headings to expand. Each of the toggle-able items have ids. It works great for users who start at the homepage.
However, when I send people to any of the inner topics, all they see is the initial collapsed state of the site. I want to be able to provide a URL that will set the toggle to open, and show all of the content for that section on entry.
Here is my code and js, can anyone point me in the right direction?
At the link below I've built the nav using CSS (see code below). How do I make the 'on' state stay active on each specific page? (i.e the 'about us' rollover image stays active on the 'about us' page)
I need to detect if page loaded or not with a script (in a child frame). The IE has a special readyState function, is there anything similar for Mozila browsers?
i have a form, and for the user to upload a file, i use window.open with my upload script. however, after the file is uploaded, i want the filename to be put back on the original page in an input text field. how would i go about doing this?
I have a scripts which filters a list of data based on a users selection from dropdowns in a form. The script updates a counter while the user is making the selections and also colates a url string which I then use to query a php db when the user clicks view results.
I also have a reset button in the form so the user can quickly go back to the start. When this is clicked it does reset all the dropdowns and inputs to their defualt values but it doesn't reset my js functions back to their initial states.
Can anyone tell me how I can do this? Is there a js reset function I can use?
Here is what I am doing:Someone clicks 'add buyer' link on my pageIn a modal box, I load the form to add a buyer. The form is loaded via ajax and then fills the div containerwhen someone clicks the 'submit' button, it should then look at the value of the fields and post to a scriptCurrently I can't get jQuery to see node within the loaded AJAX.
I have a 'to do' item in a page that has an ID attached to it. These items are stored in a database. When clicked I want to reverse the 'state' of the item (active to complete or complete to active) by updating the database using jquery & PHP.I think I almost have it. As all the values are collected ok and if I change the the page that writes to the database to GET and pass the data through the URL it updates the database fine.[code]
And my problem is when I use 'submit' button for first time on site jQuery seems to not get it and form is being posted as normal HTML form. Every next submition is posted using jQuery until I reload the site.
I have a switch/case statement, and when a case is tripped, I'd like to send a name and value to a processing page. I'm very new at jQuery with no javaScript background.
This is what I'm attempting at the moment, links is an array. Should this work? I understand that HTML headers cannot contain complex datasets like arrays, so what format is the data sent in? Ie. how do I decompose the array on the PHP end? Or is there a better way entirely of doing this?
I want to read the ID from an anchor tag and then insert it into the parent paragraph tag.This is to be repeated for all paragraphs on the page that contain anchor tags. The script is intended to run on page load.I developed the following script but it doesn't work.I got the process to work for a single paragraph but once I modifiedthe script to attempt to loop it failed.I've looked around for examples to use as learning but can't anything that matches my needs.