To work properly router needs a parameters names. By default, "Ext Direct" protocol prior to forth version does not support the parameter names in requests. But it can be corrected by adding the following "patch" after the initialization ExtJs/Sencha Touch:

/* 
	Patch for ExtJS 3.0 and lower that forces sending parameters names.
	Paste this piece of code in so-it loads after ExtJs/Sencha.
*/
(function () {
	var proto = Ext.direct.RemotingProvider.prototype;

	var getCallData = proto.getCallData;
	var connect = proto.connect;
	var mixin = {
		connect: function () {
			connect.apply(this, arguments);
			this.on('beforecall', function (p, t) { Ext.each(p.actions[t.action], function (m) { if (m.name == t.method) t.params = m.params }); }, this);
		},
		getCallData: function (t) {
			var d = getCallData.apply(this, arguments);

			d.params = t.params;
			if (Ext.isArray(d.data)) { // if arguments is array
				var data = {};
				for (var i = 0; i < d.data.length; i++) data[t.params[i]] = d.data[i]; // convert arguments to hashtable from array
				d.data = data;
			}
			return d;
		}
	};

	Ext.apply(proto, mixin);
})();

Last edited Apr 27, 2012 at 2:02 PM by ShaiHulud, version 5

Comments

No comments yet.