GithubHelp home page GithubHelp logo

Comments (6)

marijnh avatar marijnh commented on May 11, 2024

Hello Matt,

I setup this handler in an instance of CodeMirror 2 and it's executed only on component creation time, on setValue() and when 'delete' key is pressed. I would expect onChange to be executed on every keystroke that results in editor's content change.

This would be a bug. However, it is not something that I can
reproduce. It seems to work fine for me. Please verify that you're
setting up your handler correctly and not, for example, calling it
when you're passing it to CodeMirror, instead of passing the function
value.

Best,
Marijn

from codemirror5.

edmellum avatar edmellum commented on May 11, 2024

I'm having this problem too and can't even see any mention of onChange in the source. I'm probably doing something wrong, but seeing the actual code that's handling this would probably help. Could you point me in the right direction?

from codemirror5.

marijnh avatar marijnh commented on May 11, 2024

In the current version, line 1221 in lib/codemirror.js calls the
onChange handler.

from codemirror5.

mattpap avatar mattpap commented on May 11, 2024

I was a little too fast with reporting this issue, because onChange works with my webapp when the editor is attached to the top-level element (document > div), but fails (as described previously) when the editor is attached to an ExtJS window. I embed multiple editors in a single window, so I thought that they might interfere with each other, but this is not the case. For now I'm not sure which part of my webapp make the editor fail, but when I will find out, I will post my findings here.

from codemirror5.

edmellum avatar edmellum commented on May 11, 2024

Ah, I was actually browsing the old CodeMirror repo, not the CodeMirror2 one, so now I can see everything clearly.

So what I figured out is that the onChange function I supplied is called once right away before the editor is properly initialized for some reason and therefore does not receive the editor in its argument. A simple if check fixed it, but I've never experienced something like it with a Javascript library before.

from codemirror5.

mattpap avatar mattpap commented on May 11, 2024

It seems that recent commit (65f257b) fixed this issue for me, so I'm closing it as not valid anymore.

from codemirror5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.