質問

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