I'm just starting to look at Ext Direct, and I'm trying to get namespaces to work with it. However, I'm not having much luck.

Following the documentation (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.direct.RemotingProvider-cfg-disableNestedActions) I tried this:

Ext.Direct.addProvider({
    url: 'router',
    type: 'remoting',
    actions: {
        TestAction: {
            name: 'foo',
            len:  1
        },
        'TestAction.Foo': {
            name: 'bar',
            len: 1
        }
    },
    namespace: 'MyApp'
});

MyApp.TestAction.Foo.bar();

However, I'm now getting the error 'object has no method bar'.

Does anyone know why this is happening?

Thanks

有帮助吗?

解决方案

Methods definitions must be array of objects, not objects.

This way, no error:

Ext.Direct.addProvider({
    url: 'router',
    type: 'remoting',
    actions: {
        TestAction: [{ // <= Here, array!
            name: 'foo',
            len:  1
        }],
        'TestAction.Foo': [{
            name: 'bar',
            len: 1
        }]
    },
    namespace: 'MyApp'
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top