PDA

View Full Version : generated code uses "me" which is not defined



mplezbert
28 Oct 2016, 12:01 PM
When adding an event binding for exception, the following code is generated

proxy: {
type: 'ajax',
url: 'myUrl',
reader: {
type: 'json',
rootProperty: 'myRoot',
listeners: {
exception: {
fn: me.onJsonException,
scope: me
}
}
}
},

This causes a run time error that "me is undefined".

I am using architect 4.0.2.209 and ext 6.2.0.981.

mplezbert
28 Oct 2016, 12:02 PM
(Saving the post messed up my code formatting for some reason, but hopefully you get the idea.)

petr.vecera
28 Oct 2016, 3:43 PM
Hello

Thank you for the report. Could you please post info about your framework version and in which class this occurs?
I believe that this is in the store in viewmodel in the modern62 right? We are tracking this. In this case please use view controller event binding.

Thank you

alexandre.barbosa
27 Mar 2017, 3:44 AM
Hi All.

I have the same error creating an event binding in a store. When I selecte from the combo the event type, is generated a listeners with the event, where the scope is "me".

Ext.define('PmsPoc.store.xptoStore', {
extend: 'Ext.data.Store',
alias: 'store.me',
requires: [
'PmsPoc.model.KaNxModel',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
config: {
me: 'this'
},
autoDestroy: true,
storeId: 'xptoStore',
autoLoad: false,
model: 'PmsPoc.model.KaNxModel',
proxy: {
type: 'ajax',
url: 'data/gridPanel1_data.json',
reader: {
type: 'json',
rootProperty: 'items'
}
},
listeners: {
beforeload: {
fn: me.onJsonstoreBeforeLoad,
scope: me
}
}
,
onJsonstoreBeforeLoad: function(store, operation, eOpts) {
}
});

petr.vecera
27 Mar 2017, 5:17 AM
Hi Alexander

Are you on the latest version of the SA aka 4.1.2 or 4.1.1 ?? Which framework are you using? Could you describe the steps to create such store?

My basic store looks like this:


Ext.define('MyApp.store.MyStore', {
extend: 'Ext.data.Store',


requires: [
'Ext.data.field.Field'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
storeId: 'MyStore',
fields: [
{
name: 'one'
},
{
name: 'two'
},
{
name: 'three'
}
],
listeners: {
add: {
fn: me.onStoreAdd,
scope: me
}
}
}, cfg)]);
},


onStoreAdd: function(store, records, index, eOpts) {


}


});

alexandre.barbosa
27 Mar 2017, 5:49 AM
Sencha Architect



version:
4.0.0.168





channel:
4.0-stable





platform:
1.2.3.16 - win32 x64





cmd:
6.2.0.103





framework:
Ext JS 6.2.x Classic





So, I create the store using the button "+" in the Project Inspector and after I set some configs, like storeId, model, etc... After that, in the properties/config panel (rigth bottom corner), I create the function in Basic Event Bindings, selection beforeload and the previous javasscript was generated.

senacle
8 Jan 2018, 5:21 AM
For me, the bug doesn' appear in the proxy config of the store, but in the proxy config of the model of the store.
I'm trying to apply the sample provided in the sencha doc http://docs.sencha.com/extjs/6.5.2/modern/Ext.data.proxy.Rest.html to perform a crud action.

Version: 4.2.2.282
Channel: 4.2-stable
Platform: 1.6.2.49 - win32 x64
Renderer: 56.0.2924.87
Cmd: 6.5.2.15
Framework: Ext JS 6.5.x Classic