Question

BUTTON - CANNOT READ PROPERTY 'APPLY' OF UNDEFINED

Hi guys,

I'm trying to add another button to Social Feed messages.

I extended SocialFeed and modified the ESNFeedConfig like this:

 

 addResolveButtonConfig: function(){ 
                //return if config was modified 
                if(ESNFeedConfig.IsModified){
                    return;
                }
                //get initial config of post
                 var postConfig = ESNFeedConfig.postConfig; 
                 //get the location where need to add the button
                 var actionsConfig = postConfig.items[0].items[4].items[1].items; 
                 //create config for new button
 
				var resolveButtonConfig = {
					className: "Terrasoft.Button",
					style: Terrasoft.controls.ButtonEnums.style.GREEN,
					click: {bindTo: "onResolvedOnlyClick"},
					caption: "Resolve",
					visible:true,
					classes: {
						imageClass: ["actionsButtonImage"],
						textClass: ["actionsButtonText"], 
						wrapperClass: ["actionsButtonWrap", "actionsColor", "likeButtonImageConfig"]
					},
					markerValue: "Resolve"
				};
                 //add button to the array
                 actionsConfig.splice(6, 0, resolveButtonConfig); 
                // change the config
 
                 ESNFeedConfig.postConfig.items[0].items[4].items[1].items = actionsConfig; 
                 ESNFeedConfig.IsModified = true;
                },

Added the button perfectly where I need it but clicking on it is showing the following error in the console:

polyfills-es5.js:1 Uncaught TypeError: Cannot read properties of undefined (reading 'apply')
    at i.callModelMethod (all-combined.js:41:208448)
    at i.<anonymous> (all-combined.js:41:205561)
    at i.fire (all-combined.js:6:100085)
    at i.continueFireEvent (all-combined.js:6:115389)
    at i.fireEventArgs (all-combined.js:6:115170)
    at i.fireEvent (all-combined.js:6:114998)
    at i.onClick (all-combined.js:41:1120628)
    at HTMLSpanElement.eval (eval at cacheableFunctionFactory (all-combined.js:6:5209), <anonymous>:6:13)
    at HTMLSpanElement.k (all-combined.js:6:108390)
    at t.value (polyfills-es5.js:1:22418)

I defined the click method in the same place where created the configuration. What I'm missing? 



Similar to this post: https://community.terrasoft.ua/questions/button-cannot-read-property-ap…

In the last message that post suggest something about adding the click method in the ViewModel, but not sure what that means.

Any help would be really appreciated!

Thanks!

 

 

 

Like 1

Like

1 comments

Hello,

 

The message states that the button has no click-handler so it seems that the click handler (onResolvedOnlyClick) should be added not in the ESNFeedConfig, but somewhere else. Try debugging the click event and identify where the issue comes from according to the call stack.

 

Best regards,

Oleg

Show all comments