I am trying to make a text editor with firepad and codemirror, everything works perfectly on page loading, but when I try to change the mode on button click, the function gets called but doesn’t seem to work. I am calling the following code on the onload event of the body (works perfectly): on button click event I am calling