문제

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