'Ext.Direct functions available within javascript
I have implemented Ext.Direct to return data to a Store however the directFn methods are not available within the javascript.
api.php returns
var Ext = Ext || {}; Ext.REMOTING_API = {"url":"php/api/router.php","type":"remoting","actions":{"RaStatuses":[{"name":"get_ra_statuses","len":1}]}};
router.php returns
{"type":"rpc","tid":1,"action":"RaStatuses","method":"get_ra_statuses","result":[{"ra_no":"2"},{"ra_no":"4"},{"ra_no":"6"},{"ra_no":"8"},{"ra_no":"10"}]}
...and successfully populates this store
Ext.define('CSM.store.ra.Statuses', {
extend: 'Ext.data.Store',
model: 'CSM.model.ra.Status',
proxy: {
type: 'direct',
directFn: "RaStatuses.get_ra_statuses"
},
autoLoad: true
});
However when I use this line from within a javascript function
a = RaStatuses.get_ra_statuses();
...I get
'ReferenceError: RaStatuses is not defined'
Have I misunderstood? Should Ext.Direct make this object available inside the js or was this wishful thinking?
Solution 1:[1]
This now works (ExtJS 6.0.2). I amended api.php to return...
Ext.namespace('RPC');
var Ext = Ext || {};
RPC.REMOTING_API = {
"url": "php/api/router.php",
"type": "remoting",
"namespace": "RPC",
"descriptor": "RPC.REMOTING_API",
"actions": {
"RaStatuses": [{
"name": "get_ra_statuses",
"len": 0
}]
}
};
Ext.direct.Manager.addProvider(RPC.REMOTING_API);
This call now returns data
RPC.RaStatuses.get_ra_statuses();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eddie |
