stylesheet is undefined

811 views
Skip to first unread message

Emanuele Ziglioli

unread,
Feb 27, 2012, 10:57:27 PM2/27/12
to SlickGrid
Hi,

I've upgraded to the latest release and am getting some errors, here:

var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if ((sheets[i].ownerNode || sheets[i].owningElement) ==
$style[0]) {
stylesheet = sheets[i];
break;
}
}

// find and cache column CSS rules
columnCssRulesL = [], columnCssRulesR = [];
var cssRules = (stylesheet.cssRules || stylesheet.rules);


It never seems to get to stylesheet = sheets[i].
The funny thing, is that this error seems to happen randomly (maybe it
depends on a loading order, or caching). Has anybody seen this?

Thank you
Emanuele

Michael Leibman

unread,
Feb 28, 2012, 1:35:56 PM2/28/12
to slic...@googlegroups.com

Emanuele Ziglioli

unread,
Feb 28, 2012, 3:56:08 PM2/28/12
to SlickGrid
Indeed, sorry I should have looked for it on github first.
I'll try the fix Magiconair suggested

On Feb 29, 7:35 am, Michael Leibman <michael.leib...@gmail.com> wrote:
> Is thishttps://github.com/mleibman/SlickGrid/issues/223?

Emanuele Ziglioli

unread,
Feb 28, 2012, 5:08:28 PM2/28/12
to SlickGrid
this thing is driving me nuts.

I log "document.styleSheets.length" before and after calling "$style =
$("<style type='text/css' rel='stylesheet' />").appendTo($("head"));"

In one case, the example at "http://mleibman.github.com/SlickGrid/
examples/example-grouping", the length gets incremented, in another
case (my code), it does not!

Why does that style has to be created at runtime?
I can't try the patch because the method findCssRule() is not there

Anyway, there must be something going on in WebKit (and my code) so
that document.styleSheets doesn't get updated.
I can find very little about it on the net, other than bug reports.

Thanks,
Emanuele

On Feb 29, 9:56 am, Emanuele Ziglioli <theb...@emanueleziglioli.it>
wrote:

Michael Leibman

unread,
Feb 28, 2012, 5:12:27 PM2/28/12
to slic...@googlegroups.com
Does your page have a HEAD element?

Emanuele Ziglioli

unread,
Feb 28, 2012, 5:47:40 PM2/28/12
to SlickGrid
> Does your page have a HEAD element?

Yes it does.

It seems like it takes some time for Chrome to update
document.styleSheets.
I've implemented a counter with a callback as they do here:
http://www.zachleat.com/web/load-css-dynamically/

I can carry on this discussion on the Github if you prefer
https://github.com/mleibman/SlickGrid/issues/223?

On Feb 29, 11:12 am, Michael Leibman <michael.leib...@gmail.com>
wrote:
>

Michael Leibman

unread,
Mar 28, 2012, 5:37:15 PM3/28/12
to slic...@googlegroups.com
I've submitted a fix.  Will roll it into 2.0.1.

Emanuele Ziglioli

unread,
Mar 28, 2012, 8:08:51 PM3/28/12
to SlickGrid
Great! did you see that problem occurring?

On Mar 29, 10:37 am, Michael Leibman <michael.leib...@gmail.com>
wrote:

Michael Leibman

unread,
Mar 28, 2012, 8:11:05 PM3/28/12
to slic...@googlegroups.com
No, I didn't really test it, but the fix should work.

Emanuele Ziglioli

unread,
Mar 28, 2012, 9:43:39 PM3/28/12
to SlickGrid
Ok I'll verify it on my machine asap.

Emanuele Ziglioli

unread,
Apr 4, 2012, 11:10:25 PM4/4/12
to SlickGrid
Sorry for the delay, it's not working

Uncaught Error: Cannot find stylesheet.
getColumnCssRulesslick.grid.js:832
applyColumnWidthsslick.grid.js:994
updateCanvasWidthslick.grid.js:361
updateRowCountslick.grid.js:1440
resizeCanvasslick.grid.js:1378
finishInitializationslick.grid.js:266
initslick.grid.js:234
SlickGridslick.grid.js:2814

Running on Chrome 11.0.696.77, Ubuntu 11.04 32 bit

On Mar 29, 1:43 pm, Emanuele Ziglioli <theb...@emanueleziglioli.it>
wrote:

Sam Blowes

unread,
Apr 5, 2013, 5:35:41 AM4/5/13
to slic...@googlegroups.com
I'm also getting this error.
Reply all
Reply to author
Forward
0 new messages