I have run into the same issue with other types of fields when they are in repeaters and flex fields. The issue is that the editor is not initialized in the editor until the row is added so the your initialization script may not be running.
Out of curiosity, if you save the post with a layout in the flex content does your button appear in the editor when the page reloads?
You need to build your script in such a way that it can be called on ready and append actions in ACF.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users