Mayur Lunawat
Mayur Lunawat

Reputation: 97

How to add parameters to callback functions?

renderingContent:function(widget){
    uilayer.confirm("", this.renderingContextWidgetOnOkClick,this.contextChangeCancelHandler);
}

renderingContextWidgetOnOkClick:function(widget){
        console.log(widget);
}

How do I pass widget parameter which I get in renderContent function to the callback this.renderingContextWidgetOnOkClick which gets invoked on click of OK as I cannot call this.renderingContextWidgetOnOkClick(widget) as then the function gets invoked directly without ok clicked?

Upvotes: 2

Views: 50

Answers (1)

Hacketo
Hacketo

Reputation: 4997

You can wrap it in a function

renderingContent:function(widget){
    uilayer.confirm("",   
        (function(that, widget){ 
            return function(){
                that.renderingContextWidgetOnOkClick(widget);
            };            
        })(this, widget),this.contextChangeCancelHandler);
}

Upvotes: 3

Related Questions