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

how to make textarea didn't change line ... #4937

Closed
MoonBottle opened this issue Feb 15, 2017 · 3 comments
Closed

how to make textarea didn't change line ... #4937

MoonBottle opened this issue Feb 15, 2017 · 3 comments

Comments

@MoonBottle
Copy link

https://jsfiddle.net/wangmin/rdjjpc7a/1628/
in this demo,when i click enter
i used e.stopPropagation() and e.preventDefault()
but it not work
it will change a new line
i do not want that
how to avoid ...
thank u

@danieldiekmeier
Copy link

There are several things wrong with your example:

Instead of @keyup.onEnter="update", you have to call @keyup.enter="onEnter", because the name of your method is onEnter, not update, and the name of the modifier is enter, not onEnter.

Second: The newline is put into the textarea on keydown, not on keyup, so the complete code should be:

<div id="editor">
  <textarea :value="input" @keydown.enter="onEnter"></textarea>
</div>

Here is an updated fiddle: https://jsfiddle.net/tedt89kv/


Also, keep in mind that your users may Copy and Paste text with newlines into your document. Maybe a Watcher would be more what you want. In the watcher, you could remove all newlines on every change of the textarea's value.

@danieldiekmeier
Copy link

Also, from the issue template that you removed to post your question:

The issue list of this repo is exclusively for bug reports and feature requests. For simple questions, please use the following resources:

@MoonBottle
Copy link
Author

thank u ... i will think more next time

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

No branches or pull requests

2 participants