Question

Uncaught TypeError: Cannot read property 'changeMethod' of undefined

Hi everyone, 

When I try to use the change event to bindTo a function, I get the following error : "Uncaught TypeError: Cannot read property 'changeMethod' of undefined".

In my diff schema, the change event has a bound function: 

{
    "operation": "insert",
    "name": "Product",
    "values": {
        "layout": {
            "colSpan": 12,
            "rowSpan": 1,
            "column": 0,
            "row": 1,
            "layoutName": "MyLayout"
        },
        "bindTo": "MyLookup",
        "contentType": Terrasoft.ContentType.LOOKUP,
        "enabled": true,
        "change": {
            bindTo: "setProduct"
        },
        "contentType": 3
    },
    "parentName": "MyLayout",
    "propertyName": "items",
    "index": 1
}

And I call it's method handler with the following. 

setProduct: function() {
    console.log("Success!");
}

Adding the "change": { bindTo: "setProduct" } causes the page to not load. Is there a way to activate a JavaScript function when a select element on a page is changed? I need to change the values in a corresponding select element based on the value of the preceding select element.

Like 0

Like

1 comments

Hi,

In order to overcome such issue, please, check that you have binded to an existing lookup "MyLookup". Also, you can try another change method approach. 

In the onEntityInitialized function do the following:

onEntityInitialized: function(){
  this.callParent(arguments);
  this.on("change:Product", this.setProduct, this);
}

Hope this helps.

Regards,

Anastasia

Show all comments