PDA

View Full Version : twintrigger error: b[d.xtype || e] is not a constructor



nathanblogs
20 Nov 2009, 1:43 AM
Hi,

I have been upgrading from 2.2 to 3.0 and I'm getting this error whenever I try make an xtype: twintrigger.

This is the code I use inside the items of a form.




{ anchor: '100%',
hideTrigger1: true,
xtype: 'twintrigger',
emptyText: 'Please search...',
fieldLabel: 'label',
id: 'twin-id',
name: 'Names',
onTrigger1Click: function() {
// do stuff

, onTrigger2Click: function() {
// do other stuff

, readOnly: true,
trigger1Class: 'x-form-clear-trigger',
trigger2Class: 'x-form-search-trigger',
validateOnBlur: false,
validationEvent: false
}

20 Nov 2009, 7:37 AM
must be a paste error, but the code looks incomplete

CrazyEnigma
20 Nov 2009, 8:31 AM
twintrigger doesn't look like it is a registered xtype.

I looked under the Component in the EXT JS 3.0 API and it isn't documented there nor documented under TwinTriggerField.

It's actually an abstract class. So I don't know if you have registered this xtype yourself.

VinylFox
20 Nov 2009, 8:38 AM
I don't see 'twintrigger' defined as an xtype anywhere in the 2.x or 3.x branches, so im surprised that works for you in 2.x.

The docs say "TwinTriggerField is not a public class to be used directly." which explains why its not defined as an xtype.

I suppose you could register it as an xtype, though im not sure of the problems that might create.


Ext.reg('twintrigger', Ext.form.TwinTriggerField);

aw1zard2
20 Nov 2009, 8:39 AM
Yeah you get that error when your xtype is typed wrong or doesn't exist.

Not that I know from experience or anything. lol OK maybe I do. :))

CrazyEnigma
20 Nov 2009, 8:58 AM
I don't see 'twintrigger' defined as an xtype anywhere in the 2.x or 3.x branches, so im surprised that works for you in 2.x.

The docs say "TwinTriggerField is not a public class to be used directly." which explains why its not defined as an xtype.

I suppose you could register it as an xtype, though im not sure of the problems that might create.


Ext.reg('twintrigger', Ext.form.TwinTriggerField);

Is it not an Abstract Class? you will have to extend the class first before you register. So Ext.form.TwinTriggerField will definitely, or at least in theory throw an error.

VinylFox
20 Nov 2009, 10:40 AM
Is it not an Abstract Class? you will have to extend the class first before you register. So Ext.form.TwinTriggerField will definitely, or at least in theory throw an error.

Yes and no - it will show up and 'work', it just does not have any functionality attached to the triggers. Just eye candy in its current state.

Should definitely extend this class and register your extended class instead.

Technically you could do something like this, but it seems a bit silly.


Ext.reg('twintrigger', Ext.form.TwinTriggerField);
new Ext.form.FormPanel({
renderTo: Ext.getBody(),
items: [{
xtype: 'twintrigger',
onTrigger1Click: function(){
Ext.Msg.alert('hi','Hello1');
},
onTrigger2Click: function(){
Ext.Msg.alert('hi','Hello2');
}
}]
});

nathanblogs
20 Nov 2009, 7:04 PM
Thanks for the comments and feedback, I'm going away for the weekend so I wont be able to look at these till late Sunday.

nathanblogs
22 Nov 2009, 7:14 AM
must be a paste error, but the code looks incomplete

It was the code inside of a formpanels items
I don't see 'twintrigger' defined as an xtype anywhere in the 2.x or 3.x branches, so im surprised that works for you in 2.x.

The docs say "TwinTriggerField is not a public class to be used directly." which explains why its not defined as an xtype.

I suppose you could register it as an xtype, though im not sure of the problems that might create.


Ext.reg('twintrigger', Ext.form.TwinTriggerField);

Setting:
Ext.reg('twintrigger', Ext.form.TwinTriggerField); fixed the issue.