Dynamically Adding onClick Events

Hello,
Im trying to dynamically add function code to an onClick property.
I have an accordion item (with name ‘accitem1’) for which I added and icon to the header: class=‘hide webix_icon fa fa-eye-slash’

The UI is created dynamically after which triggers are attached at run time. I get the following string for the onClick property of the accordionitem “‘hide’:function(event, id) {hideOrShowRhsPanel(‘hide’);return false}”

I’m trying to use the following code to attach the function where ‘input_string’ is the string mentioned above
and ‘accordionitem’ is initialized by using the ‘queryView’ function of the form that the accordion is defined in:

   	var accordionitem = parentform.queryView({name:'accitem1'});			
var class_function = input_string.split(":");				
if (class_function.length > 0) {
	var clickclass = class_function[0];											
	if (clickclass) {
		var fn = new Function("'use strict';return (" + class_function[1] + ")")();
		accordionitem.on_click[clickclass] = fn;
	}
}

Displaying the values of accordionitem, fn and clickclass all display the right values.
What am I missing? Is there a different way to attach a function to the onClick property for a class?

Thanks,
Pieter