jquery-cookie

handling large cookies or using local storage - jquery and jquery cookie plugin

瘦欲@ 提交于 2020-01-25 17:54:51
问题 I have the working code which sets and clears cookie (remembers div's style) on click: var originalAttributes = $('.aaa').attr('style'); $('.aaa').each(function(){ var d = $(this), id = d.attr('id'), storedStyle = $.cookie('aaaStyle' + id); if (storedStyle != undefined){ //style stored d.attr('style', storedStyle); } }); //mouse event functions for class="aaa" $('#save').click(function () { $('.aaa').each(function(){ var d = $(this), id = d.attr('id'), style = d.attr('style'); if (style !=

Jquery cookie undefined on the line after setting it?

落爺英雄遲暮 提交于 2020-01-06 19:51:27
问题 Good morning all, I'm just getting familiar with jquery cookie, but I can't seem to find out why the cookie is undefined after setting it. Basically, I'm trying to store the sort order using sortable in jquery ui in a cookie, but after setting the cookie it's still saying undefined. I'll show the jquery below, and if you guys need to see more (the html and what not, I can update to include that too). First, just to note, in the update function for sortable, if I put alert(cooked) before I set

PHP sets COOKIE, changed with JQUERY COOKIE plugin, cannot be edited with php?

浪子不回头ぞ 提交于 2020-01-06 04:25:11
问题 i'm using some simple code as a test as my page isn't working, maybe i'm missing something?! I have google for this problem and searched here but no one seems to have mentioned it! even on cookie tuts i have read! i have a simple setcookie php line of code: <?php if($_COOKIE['PHP1'] !== 'php'){ $blah = setcookie('PHP1','php',time() + (1000 * 120),'/','',false,false);} ?> Its at the top of the page before any html and sets the cookie PHP1 to php just fine; I then have some code on the body: <

jQuery Cookie Not Working in IE 8?

谁都会走 提交于 2020-01-05 12:13:11
问题 EDIT: I was having an issue with the cookie below so I switched to jQuery Cookie and still the error persist so I posted the jQuery Cookie code here but left my original question intact: On one page I call colorbox and that code works properly yet on another page I changed the cookie name and function called and it breaks, here is that code: var $j = jQuery.noConflict(); $j(window).load(function() { //I have also tried - $j(document).ready(function(){ - ///to see if that changed anything if(!

Retrieving references to child window if the parent refreshes

╄→гoц情女王★ 提交于 2020-01-05 03:00:29
问题 I have a page (parent.html) which has many links which on clicking opens a window as: winRef = window.open(url, '_blank', 'width=800,height=600,resizable,scrollbars'); To give a warning when the child window is closed I use the below in parent.html. var timer = setInterval(function() { if(win_ref.closed) { clearInterval(timer); alert("window closed"); console.log("name is"+name); list.remove(name); } }, 1000); This works fine. This warns user if the child window is closed. But if the parent

jQuery arrays into cookie

孤者浪人 提交于 2019-12-24 12:02:14
问题 var adddata = []; adddata[ group ] = []; adddata[ group ][ id ] = option; // option is an object like { foo : 'bar' } console.log( adddata ); // looks ok $.cookie( 'cookiename', JSON.stringify( adddata ) ); console.log( $.cookie( 'cookiename' ) ); // just "[]" $.cookie( 'cookiename', adddata ); console.log( $.cookie( 'cookiename' ) ); // "an empty string" // in another file var cdata = JSON.parse( $.cookie( 'cookiename' ) ); $.each( cdata, function( group, items ){ /* and so on */ }); As you

Saving multiple panel's collapsed state using cookies with $.cookie()

▼魔方 西西 提交于 2019-12-20 09:53:57
问题 I'm trying to determine how I might save a collapsible panel's collapsed state using $.cookie. This question has been helpful so far, but still missing the end solution. Any solutions I have found so far have only saved the last rolled down panel so when the page is reloaded the only panel saved is the last one. What I need is to save all panels that are rolled down rather than just one. Link to jCookie plugin on Github. Link to demo on JSFiddle UPDATE It has been suggested that LocalStorage

Javascript: Change CSS File Dynamically + Cookie

眉间皱痕 提交于 2019-12-18 04:27:09
问题 I want to change the used CSS File ( <link href="..." /> ) dynamically using only javascript and to save changes in cookies. This is a jQuery version that does what I want (ref), but how can I do this in javascript? if($.cookie("css")) { $("link").attr("href",$.cookie("css")); } $(document).ready(function() { $("#nav li a").click(function() { $("link").attr("href",$(this).attr('rel')); $.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'}); return false; }); }); Thank you in advance.

jquery save json data object in cookie

◇◆丶佛笑我妖孽 提交于 2019-12-17 02:42:10
问题 How do I save JSON data in a cookie? My JSON data looks like this $("#ArticlesHolder").data('15', {name:'testname', nr:'4',price:'400'}); $("#ArticlesHolder").data('25', {name:'name2', nr:'1', price:'100'}); $("#ArticlesHolder").data('37', {name:'name3', nr:'14', price:'60'}); And I want to do something like var dataStore = $.cookie("basket-data", $("#ArticlesHolder").data()); and to retrieve the data i want to load it into $("#ArticlesHolder") like $.each($.cookie("basket-data"), function(i

jquery toggle function and set a cookie

一曲冷凌霜 提交于 2019-12-14 03:26:07
问题 I have the following function which toggles mouseenter and mouseleave on click: var flag = true; $('.aaa').mouseenter(function () { if(flag) { $(this).css('background', '#aaaaaa'); } $(this).css('border', 'solid 1px red'); }); $('.aaa').mouseleave(function () { if(flag) { $(this).css('background','blue'); } $(this).css('border', 'solid transparent 1px'); }); $('#tog').click(function () { flag = !flag; }); http://jsfiddle.net/z8KuE/15/ How can chosen preference be "remembered" and loaded on