Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes made using the editor buttons doesn't trigger onchange on the textarea #308

Closed
BudgieInWA opened this issue Oct 12, 2017 · 3 comments · May be fixed by #327
Closed

Changes made using the editor buttons doesn't trigger onchange on the textarea #308

BudgieInWA opened this issue Oct 12, 2017 · 3 comments · May be fixed by #327

Comments

@BudgieInWA
Copy link

To reproduce follow these steps:

  1. Browse to the demo page at http://www.codingdrama.com/bootstrap-markdown/, or any other instance of the editor.
  2. Set up logging of the 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))
  3. Edit the content inside the textarea and then blur the textarea. Notice that the onchange event was logged to the console.
  4. Now select some text and make it bold using the editor button and blur the textarea before making any other changes. Notice that no onchange event was triggered.

An onchange event should be triggered in this case.

@eric-hemasystems
Copy link

eric-hemasystems commented Dec 10, 2019

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:

  1. The argument given to change may trigger event registration instead of event triggering. According to the docs no argument should be given to trigger events.
  2. I think 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.

@lodev09
Copy link
Contributor

lodev09 commented Dec 10, 2019

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 lodev09 closed this as completed Dec 10, 2019
BudgieInWA added a commit to BudgieInWA/bootstrap-markdown that referenced this issue Dec 11, 2019
The discussion in refactory-id#308 indicates that `this.change(this)` is incorrect, adding a listener instead of triggering a change event.
@BudgieInWA
Copy link
Author

@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?

tclaus pushed a commit to tclaus/bootstrap-markdown that referenced this issue Feb 22, 2021
The discussion in refactory-id#308 indicates that `this.change(this)` is incorrect, adding a listener instead of triggering a change event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants