最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught TypeError: Cannot read property 'apply' of undefined with Sencha - Stack Overflow

programmeradmin2浏览0评论

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.

Share Improve this question edited Sep 9, 2015 at 18:18 Kristijan Iliev 4,99710 gold badges30 silver badges51 bronze badges asked Apr 16, 2014 at 19:13 agorjuxagorjux 551 gold badge1 silver badge2 bronze badges 8
  • 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
 |  Show 3 more ments

1 Answer 1

Reset to default 0

I 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"

发布评论

评论列表(0)

  1. 暂无评论