I am trying to display a consent page in my app. The page should be written in html so the app need to handle a button clicked event from browser. I tried to replicate the example in blog (minus the jQuery part):
bc.addJSCallback(
"document.getElementById('ACCEPT').addEventListener('click', function(){callback.onSuccess(true)})",
res -> {
System.out.println(res);
dialog.dispose();
}
);
The html looks like this:
<html>
<button id='ACCEPT'>Accept</button>
<button id='DECLINE'>Decline</button>
<script></script>
</html>
Nothing happened when the button was clicked. However, when the js expression was put in the <script> tag instead, 'callback' is not defined was logged, suggesting that the js expression was not the cause.
I'd like to know which part went wrong? Any help is appreciated.
addJSCallbackafteronLoadwas invoked? - Shai Almog