user1578653
user1578653

Reputation: 5028

ExtJS 4.2.0: Ext.Direct and namespaces

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

Upvotes: 0

Views: 459

Answers (1)

rixo
rixo

Reputation: 25001

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'
});

Upvotes: 1

Related Questions