including js files with $this->strJavaScripts = 'myscript.js'; does not cache files

Login or register to post comments
1 reply [Last post]
Offline
Joined: 02/02/2010

i am experimenting with jsTree and created a QJsControl

I include the js file with
$this->strJavaScripts = __NV_JS__ . '/jsTree/jquery.jstree.js';

using this way the js method qc.loadJavaScriptFile is called
and this method calls the jquery method getScript
this method does not cache scripts!!!

the file jquery.jstree.js is 175k. So loading every time the page loads is not an option
(if you have multiple trees on the page the script is loaded multiple times)
now looking at this bug report: http://bugs.jquery.com/ticket/8487

from this bug report i found the solution (it is a very simple change)
At the moment i cannot create a ticket because I can't login to the trac system, so i post the solution here:

in qcubed.js on line ~250 replace
$j.getScript(strScript, objCallback);
with
jQuery.ajax({type: "GET",url: strScript,success: objCallback,dataType: "script",cache: true});

getScript() is just a wrapper for the new code that disables caching.

Offline
Joined: 03/31/2008

I created http://trac.qcu.be/projects/qcubed/ticket/713 for you. :) Thanks for the report!