简体   繁体   中英

How can we get the hidden properties from an object?

I have an object, which is an instance of one of my models. I want to get the store it belongs to, from that instance. When digging for a way to get this store, I found this :

_data: Object
data: Object
dirty: true
editing: false
id: "ext-record-462"
internalId: "ext-record-462"
modified: Object
phantom: true
raw: Object
stores: Array[1]
__proto__: Object
length: 1

This is the console.log() of the object, and I can see a stores variable, which contains the array of stores that this object is linked to :

stores: Array[1]
    0: Class
    length: 1
    __proto__: Array[0]

I tried myObject.get('stores') and myObject.stores , but both returned undefined . Is there a way to retrieve this information, or is it forbidden by the framework ?

Similarly, once I get the store, I would like to get the object it is linked to from a hasMany association. In the console.log() of that store, i see this :

boundTo: Class

This field contains the reference to the object that has the association. But I can't get it. I tried myStore.get('boundTo') and myStore.boundTo too, but without success.

So my question is : Is there a way to get these hidden properties ?

I'm dumb, I forgot that these objects are before all javascript objects. But in case anybody stumbles on this, I'll leave the answer here :

You can access any property of a javascript (and therefore, any models or sencha touch object) thanks to this syntax : myObject['myProperty']

All you have to do is take a look at your object thanks to a dev tool in your browser, and note down the property you want to get.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM