`change` event not fired when dropping a file into an editor

Hi guys,

Was going to raise an issue in the GitHub, but figured it best to check and see if anyone else has the same problem here first.

With dragDrop set to true, I can drop code files into the editor with ease. When this happens, however, it does not fire a change event for the <textarea> that was used to create the editor. I was able to work around this by binding to the drop event that CodeMirror fires when you drop a file, and handling the functionality manually there.

Has anyone else run into the same problem? Is this a bug with CodeMirror? Or is there a param I’m missing to set. It would be nice if dropping a file was the same as typing into the editor.

Thanks,
Graham.

You’ll see the same behavior when making changes to the editor in other ways. A CodeMirror instance hides the textarea it was based on, and only updates it when its save() method is called. You might want to listen for "change" events on the CodeMirror instance instead.

Got it OK - so this is expected behaviour. Thanks so much for the speedy reply!

What’s the benefit of listening to the change event over the drop event? When you type in the editor the change event is already fired, and that already works perfectly with a blanket $('#my-form input').on('change') setup. My application has some buttons that become disabled if a user edits anything in the form, which is why I needed this drop event specifically.

What are the other ways that would make the textarea not “change”?

Thanks again