PDA

View Full Version : ComboBox via File System



skirtle
24 Dec 2011, 10:55 AM
Instantiating a ComboBox throws an error when a page is loaded directly off the file system. Note it works fine over a web server.

Any ComboBox will do:


var combo1 = Ext.create('Ext.form.field.ComboBox', {
renderTo: Ext.getBody(),
store: ['Red', 'Green', 'Blue']
});

The same error on both Chrome and FF:


Ext.util.CSS.getRule("." + Ext.baseCSSPrefix + "form-trigger") is undefined

Ext.form.field.Trigger.prototype.triggerWidth = parseInt(Ext.util.CSS.getRule('.' + Ext.baseCSSPrefix + 'form-trigger').style.width, 10);

Animal
24 Dec 2011, 1:29 PM
I suspect that the CSS is not being loaded at all.

skirtle
24 Dec 2011, 5:50 PM
I made a more sophisticated test case to help confirm that I wasn't making a silly mistake. Here I create a panel and a button and they render successfully, confirming that the CSS has loaded. Then when I click the button to add a combobox it throws the error. Switching to 4.0.7 it works fine. Going through a web server also works fine.


Ext.create('Ext.panel.Panel', {
height: 300,
renderTo: Ext.getBody(),
title: 'Panel',
width: 300,
tbar: [{
text: 'Add',
handler: function(btn) {
btn.up('panel').add({
renderTo: Ext.getBody(),
store: ['Red', 'Green', 'Blue'],
xtype: 'combobox'
});
}
}]
});

skirtle
24 Dec 2011, 9:22 PM
It's not just comboboxes. I'm hitting the same problem with Ext.form.Labelable. Blows up here:


Ext.form.Labelable.errorIconWidth = parseInt(Ext.util.CSS.getRule('.' + Ext.baseCSSPrefix + 'form-invalid-icon').style.width, 10);

Seems there's an issue with getRule when running directly off the file system.

Animal
24 Dec 2011, 10:23 PM
This is not good!

http://code.google.com/p/chromium/issues/detail?id=45786

We need to be able to know how some things are styled, and sometimes need to ask the stylesheet.

I added my vote to fix that. I urge people to log in and add their votes.

skirtle
24 Dec 2011, 10:48 PM
Ouch.

It's not just Chrome though, FF9 is the same. Works fine in Opera...

It'd be a shame if ExtJS lost support for running off the file system, I've always found that really useful for prototyping and testing.

unkn
26 Dec 2011, 3:37 AM
Hello there
Got exactly the same problem.

Ext.util.CSS.getRule("." + Ext.baseCSSPrefix + "form-trigger") is undefined

Ext.form.field.Trigger.pro...x + 'form-trigger').style.width, 10);

As skirtle said, most of the 4.1 beta examples using combo don't work for me (Chrome 16, FF 8) !

medifirst
27 Dec 2011, 12:02 AM
Hi, the same problem throw a web server with this example:



<html>
<head>
<title>Aper├žu avant impression</title>



<link rel="stylesheet" type="text/css" href="/lib/js/extjs41/resources/css/ext-sandbox.css">
<script type="text/javascript" src="/lib/js/extjs41/builds/ext-all-sandbox.js"></script>

<script type="text/javascript">


Ext4.onReady(function()
{
Ext4.create('Ext4.container.Viewport',
{
/*Ext4.create('Ext4.panel.Panel',
{*/
renderTo: Ext4.getBody(),

items:
[{
xtype: 'combobox'
,fieldLabel: 'test combo'
,queryMode: 'local'
,displayField: 'label'
,valueField: 'id'
,store: Ext4.create('Ext4.data.Store',
{
fields: ['id', 'label']
,data:
[
{'id': 0, 'label': 'value 1'}
,{'id': 1, 'label': 'value 2'}
]
})
}
,
{
xtype: 'slider'
,width: 250
,increment: 1
,minValue: -100
,maxValue: 100
}]
});
});

</script>
</head>
<body></body>
</html>


Browser : Firefox 9.0.1

BulletzBill
3 Jan 2012, 6:00 AM
Ouch.

It's not just Chrome though, FF9 is the same. Works fine in Opera...

It'd be a shame if ExtJS lost support for running off the file system, I've always found that really useful for prototyping and testing.
I've also confirmed these issues for Chrome 16 and Firefox 9.0.1 in OS X, both running locally via file:// and from a web server.

slemmon
3 Jan 2012, 9:10 PM
I entered a bug just now with a similar issue.
http://www.sencha.com/forum/showthread.php?170663-4.1-B1-CSS.createStyleSheet%28%29-error

paipai
6 Jan 2012, 7:40 AM
Is there a fix ?
I'm patching my app for 4.1b1 since 3 days (it's not finished) ...I can't come back to 4.0.7

medifirst
6 Mar 2012, 5:03 AM
Hi,

for my example, this problem disappears with firefox 10