javascript context issue - parameters undefined

前端 未结 2 1673
萌比男神i
萌比男神i 2021-01-21 15:14

I have this code:

targetMu: function(programmeCode, muId) {

//Parameter values are fine here

  targetMuController.targetMuView.on(\"targetMu:afterRender\", fun         


        
相关标签:
2条回答
  • 2021-01-21 16:01

    try to remove parameters from anonymous function:

    targetMu: function(programmeCode, muId) {
        targetMuController.targetMuView.on("targetMu:afterRender", function() {       
            this.renderCustomWidgets(muId, programmeCode);
        });
    }
    
    0 讨论(0)
  • 2021-01-21 16:02
    , function(programmeCode, muId) {
    

    You just declared new parameters in the callback function with the same names.

    Inside the callback, these names refer to the inner parameters – whatever was passed to the callback.

    0 讨论(0)
提交回复
热议问题