PDA

View Full Version : Caching issue ?



valc
12 Jan 2007, 7:30 AM
Some backend changes that I have made do not appear in IE until I close the browser and restart. This does not happen in Firefox 2.0? Is it my IE settings or the Yahoo.ext.

I am using the following code...

var sections= getEl('sections');
sections.load(url, null,function())

Animal
12 Jan 2007, 8:12 AM
if (YAHOO.ext.util.Browser.isIE) {
YAHOO.ext.UpdateManager.defaults.disableCaching = true;
}

Animal
12 Jan 2007, 8:13 AM
or



sections.load({url:url, nocache:true}, null,function());

valc
12 Jan 2007, 9:23 AM
Thanks Animal. Will that code suffice for DataModel loading too ?

valc
12 Jan 2007, 10:15 AM
Is there a similar way to stop caching for the YAHOO.ext.grid.LoadableDataModel ?

YAHOO.ext.grid.myXMLDataModel.prototype.loadPage = function(pageNum, callback, keepExisting){
var start = (pNum-1) * this.pageSize;
start = start < 1 ? 1 : start;
var params = "&Start="+start;

this.load(this.pageUrl, params, this.setLoadedPage.createDelegate(this, [pageNum, callback]),
keepExisting ? start : true);
};

I tried to use this.load({url:this.pageUrl, nocache:true} but the refresh indicator hangs(keeps spinning) in IE when I refresh the view.

Animal
12 Jan 2007, 11:03 AM
For a LoadableDataModel you could use



myDataModel.load(url, {cacheBuster:new Date()});


Or, set it up when you initialize the paging:



myDataModel.initPaging(url, 10, {cacheBuster:function(){return new Date()});

valc
12 Jan 2007, 2:20 PM
Thanks Animal, that worked a treat. I have one last issue. The following line in yui.ext.js (lastest rel.) is giving me an error in IE but is ok in Firefox.

The last part is throwing the error eval(match[1])

var id=YAHOO.util.Dom.generateId();var dom=this.dom;html+='<span id="'+id+'"></span>';YAHOO.util.Event.onAvailable(id,function(){var hd=document.getElementsByTagName("head")[0];var re=/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img;var srcRe=/\ssrc=([\'\"])(.*?)\1/i;var match;while(match=re.exec(html)){var srcMatch=match[0].match(srcRe);if(srcMatch&&srcMatch[2]){var s=document.createElement("script");s.src=srcMatch[2];hd.appendChild(s);}else if(match[1]&&match[1].length>0){eval(match[1]);}}

When I have loadScripts enabled on a dynamically loaded page and and I have a <script> at the bottom of the page it throws a syntax error. Any ideas ? See <script> code...

<script type="text/javascript">//<![CDATA[
var hd = YAHOO.util.Dom.getElementsByClassName('dl-group-hd')
var bd = YAHOO.util.Dom.getElementsByClassName('dl-group-bd')
for (var i = 0; i< hd.length; i++){
var nav = new Nav(hd[i],bd[i]);
nav.expand();
}
//]]></script>

tryanDLS
12 Jan 2007, 3:13 PM
It might be the comment tags you're wrapping around the JS code - I think there's a post on this someplace - haven't found it yet.

valc
12 Jan 2007, 3:36 PM
It happens without the comment tags too.

This post ?
http://www.yui-ext.com/forum/viewtopic.php?t=1442&highlight=loadscripts+error

valc
12 Jan 2007, 5:26 PM
I moved the script code as I couldn't figure out why it was failing in IE. Thanks anyway.

Cheers,

Val.

Animal
13 Jan 2007, 1:50 AM
I don't think it's the comments. I use commented CDATA tags when testing my <aspicio:page xhtml="true"> JSP tag, and the <aspicio:script>s worked fine.

There are a couple of semicolons missing. :?: :?: :?:

IIRC, in the VisualStudio debugger, you can step into evals. I think I've done this. I haven't used VS since Firebug 1.0 came along (I may have to if I get errors in eval'd code - I don't think Firebug can step into evals)