Simulate "button.setEnabled" on javascript

Hello,
I want to simulate “button.setEnabled” on javascript, so i use this code:
Page.getCurrent().getJavaScript().execute(“document.getElementById(‘buttonTest’).disabled=false;”);

the button was not enabled on initialisation of my view, when i run the code javascript, my button became enabled but it doesn’t run when i click , the listener on my button (clickListener declared on my class java) does not work, my button is finally not enabled, how can i enabled my button with code javascript ?

Thank you for your help

If you have actually disabled the button in server side with setEnabled(false), I’m pretty sure you cannot change the Button state from javascript code anymore. You might be able to disable and enable it with JavaScript not actually changing the Button state in server but only in browser.

Then the mandatory question: What are you trying to achieve in the end?

in java code i was not able to get scroll position of my panel in order to enable/disable my submit button if the scroll position was in the end position. so i disable the button in initialization of the panel (java), i add a click listener on my panel to get scroll position with javascript code (because the methode getScrollPosition in java was return always 0), if the scroll position was in the end then i enable my button with javascript code.

panel.addClickListener(new ClickListener() {
@Override
public void click(ClickEvent event) {
Page.getCurrent().getJavaScript().execute(“if the scroll is in the end then i enable the button with javascript code”);

}
});