Closed BudgieInWA closed 4 years ago
I had the same problem. A change may not be captured because a button did not trigger the change event. I found the following in the code:
// Trigger onChange for each button handle
this.change(this);
I'm not very good with jQuery but I think there may be two problems with this:
change
may trigger event registration instead of event triggering. According to the docs no argument should be given to trigger events.this
is the container for the markdown field. In general I think this is the textarea
element but there is also some sort of inline editing support. In that case maybe it isn't?. Other code seems to refer to this.$textarea
to explicitly target the textarea (which I think is what we want).Given those two issues I change the code to:
this.$textarea.change();
Interactive testing seemed to show that this works.
this
is the instance of the Markdown
object itself -- not the Texarea
element. @eric-hemasystems is correct, use this.$textarea
as this holds the element itself.
@lodev09 the bug that you have confirmed in your comment exists within this repo, it is not something that users of this library can change. Can this issue be re-opened until the fix is merged?
To reproduce follow these steps:
onchange
events for the textarea by executing the following in the browser console. This selects the first textarea in the demo page at the time of writing.$('textarea[name=content]').change(console.log.bind(console))
onchange
event was logged to the console.onchange
event was triggered.An
onchange
event should be triggered in this case.