GithubHelp home page GithubHelp logo

Edit input value about wysihtml5 HOT 8 CLOSED

tiff avatar tiff commented on September 2, 2024
Edit input value

from wysihtml5.

Comments (8)

tiff avatar tiff commented on September 2, 2024

Hi @tonyouyang,

sorry I don't really understand what you mean. Can you elaborate?
Thanks!

from wysihtml5.

tonyouyang avatar tonyouyang commented on September 2, 2024

Hi @tiff ,
I intended to revise the content in textarea. I've got it done. Sorry to bother!

from wysihtml5.

pkimbrel avatar pkimbrel commented on September 2, 2024

Can I ask - what was the solution? I think I'm trying the same thing to no avail.

I want to update the entire value of the text area with a completely new value. I'm using jQuery:

$("#content").val("this is <b>new</b> content");

Where "content" is my text area. I see the text area getting the new value, but the wysihtml5 doesn't update. Any modification to the wysihtml5 side then reverts my text area.

How does one request the wysihtml5 area to refresh?

from wysihtml5.

tonyouyang avatar tonyouyang commented on September 2, 2024

Hi @pkimbrel . I didn't "refresh". I just set textarea's value before initializing of wysihtml5.

from wysihtml5.

tiff avatar tiff commented on September 2, 2024

Hey @pkimbrel,

try wysihtml5.Editor.prototype.setValue.

Example:

myEditor = new wysihtml5.Editor("...");
// ...
myEditor.setValue("<p>foobar</p>", true);

from wysihtml5.

pkimbrel avatar pkimbrel commented on September 2, 2024

That did the trick! Thanks guys!

Another quick question. I see from the source code that the 2nd parameter of setValue() (the boolean) is "parse". What is the implication of setting that to false? I tried it with "false" and it still worked. I will say, though that I had valid markup. Is that a safety in case I try to set invalid markup?

from wysihtml5.

tiff avatar tiff commented on September 2, 2024

If the second parameter is true wysihtml5 will run the html through the parser to make sure the html matches the given parser rules before displaying it.

For example if you disabled iframe tags in your parser rules then this html:
<p>foobar</p><iframe src="http://www.google.de"></iframe>
will be converted to
<p>foobar</p>

It's recommended to always set it to true since the html will anyway be parsed at some time (eg. before the form gets submitted)

from wysihtml5.

pkimbrel avatar pkimbrel commented on September 2, 2024

@tiff Awesome! Thank you very much. Love this plug-in!

from wysihtml5.

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.