Add javascript code in custom field format

Hi Community,

I'm trying to implement a custom field formatter, which displays a button and when user click this button, an HTTP post request will be sent, and the response will be in a popup window displayed. Now the button is correctly displayed, however when user clicks the button, the function binded to onClick event is not fired. I guees, somehow angularjs has taken over the event and it is not captured by browser. And I noticeed that the output of my custom field formatter is wrapped in a tag

<span ng-non-bindable>

Can someone please explain me, why the javascript function binded to onClick event can't be executed? Is it possible to add eventlistener to an element in a custom field formmatter?

Thanks a lot!
Dingjun

I am not aware of any limitations on this and I've also asked the Kibana security team about it and they said there shouldn't be any limitations to that. Can you give us more details on how you're implementing this? Is it a custom one or just overwriting an existing one?

Hi Marius,

I'm implementing a custom one, not overwritng an existing one. Basically my custom field formatter returns html code like this:

 <button id="button">Show Message</button>
 document.getElementById("button").onclick = function () { 
 //more javascript code here
 };

The problem is when I click the button, the code bound to onlick event is not executed.

Thanks
Dingjun

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.