I have some problems with sencha touch. I have this simple code :
items: [
{
name: "horo",
xtype: 'togglefield',
label: 'Horodateur ?',
labelWidth: '55%',
disabled: false,
listeners: {
beforechange: function (slider, thumb, newValue, oldValue) {
if (oldValue == 0 && newValue == 1) {
alert("toto");
}
},
change: function (slider, thumb, newValue, oldValue) {
if (oldValue == 0 && newValue == 1) {
alert("titi");
}
else if (oldValue == 1 && newValue == 0)
alert("tata");
}
}
},
And I have this error on my console :
Uncaught TypeError: Cannot read property 'apply' of undefined.
What's the problem ?
My console say something else, maybe the Controller.js
is the problem.
I have some problems with sencha touch. I have this simple code :
items: [
{
name: "horo",
xtype: 'togglefield',
label: 'Horodateur ?',
labelWidth: '55%',
disabled: false,
listeners: {
beforechange: function (slider, thumb, newValue, oldValue) {
if (oldValue == 0 && newValue == 1) {
alert("toto");
}
},
change: function (slider, thumb, newValue, oldValue) {
if (oldValue == 0 && newValue == 1) {
alert("titi");
}
else if (oldValue == 1 && newValue == 0)
alert("tata");
}
}
},
And I have this error on my console :
Uncaught TypeError: Cannot read property 'apply' of undefined.
What's the problem ?
My console say something else, maybe the Controller.js
is the problem.
- Many times I see that error when either the xtype doesn't exist, or I'm calling a function that doesn't exist (like if I have a typo in the function name). – forgivenson Commented Apr 16, 2014 at 19:34
- 1 Use Google Chrome's DevTools. Set "Pause on Exception" in your "Sources" tab, and then walk back up the call stack to see where the problem originates. – arthurakay Commented Apr 16, 2014 at 21:10
- I had code win.callback(win, {}); for a dialog window, and fixed it by using win.close(). Not sure if you have similar code that's not displayed here? – JustBeingHelpful Commented Jul 9, 2014 at 21:43
- 1 I'd suggest adding a plete example to fiddle.sencha. – Peter Kellner Commented Aug 1, 2014 at 15:53
- 1 Sometimes you can see errors like this if you add items to a ponent in the initComponent() method. In some cases if you move the callParent(); call above where you are adding the items error will be resolved. – Greg Lafrance Commented Oct 30, 2014 at 18:08
1 Answer
Reset to default 0I had the same problem. This problem can occur when you define some listeners and you did not define the function in your controller. I can see that beforechange and change have functions so maybe there are more items in your code that you have not shown here in the forum. If there are listeners and the listener referer to a function that do not exist then you will get an error. "Uncaught TypeError: Cannot read property 'apply' of undefined"