PDA

View Full Version : Cookies state management not working



ketanmaheta
2 Apr 2013, 6:54 AM
Hi All,
I am trying to save state of accordion for testing purpose but it is not working. I am not getting any error. In my test.html page, I am referring the required .css file along with ext-all-debug.js and the following js file.The code of js file is as below. I am referring example provided on http://examples.extjs.eu/

Ext.BLANK_IMAGE_URL = './ext/resources/images/default/s.gif';


var cp = new Ext.state.CookieProvider({
expires: new Date(new Date().getTime() + (1000 * 60 * 60 * 24 * 30)) //30 days
});
Ext.state.Manager.setProvider(cp);


// application main entry point
Ext.onReady(function () {


var w = new Ext.Window({
title: Ext.fly('page-title').dom.innerHTML
, renderTo: Ext.getBody()
,stateId:'mywindowPnl'
, layout: 'accordion'
, width: 300
, height: 300
, closable: false
, stateful: true
, border: false
, layoutConfig: { animate: true }
, defaults: {
stateEvents: ["collapse", "expand"]
, getState: function () {
return { collapsed: this.collapsed };
}
, bodyStyle: 'padding:8px'
, border: false
}
, items: [{
stateId: 'first'
, title: 'First'
, html: 'First'
, collapsed: false
}, {
stateId: 'second'
, title: 'Second'
, html: 'Second'
, collapsed: true
}, {
stateId: 'third'
, title: 'Third'
, html: 'Third'
, collapsed: true
}, {
stateId: 'fourth'
, title: 'Fourth'
, html: 'Fourth'
, collapsed: true
}]
});
w.show();
});

slemmon
4 Apr 2013, 11:25 AM
I'm not having trouble with Saki's Ext Examples page saving state for me.
I'm also not having trouble with state management using the example page here:
http://docs.sencha.com/ext-js/4-2/extjs-build/examples/state/state.html

You might test and see if that second link there works for you.
If so, you can leverage its code for your tests.

If not, then perhaps the issue is related to cookie management on your browser or browsers.

As an aside, when posting sample code snippets you should wrap your code using the code tags for thread readability.
Also, if you have an inline, un-tabbed, script example it would be benefit readability if you indent each code block (you can paste and beautify code here: http://jsbeautifier.org/).