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

send value to editor from JS #45

Closed
ddmitr opened this issue Apr 21, 2014 · 24 comments
Closed

send value to editor from JS #45

ddmitr opened this issue Apr 21, 2014 · 24 comments

Comments

@ddmitr
Copy link

ddmitr commented Apr 21, 2014

Can't add text to editor.

$('#editor').val('Some text');

But this does not work.

@thenitai
Copy link

No that I have a solution, but I can re-create this. The value of the textarea can not be set with JS.

@ddmitr
Copy link
Author

ddmitr commented Apr 22, 2014

And what should I do?

@manikantareddygk
Copy link

pass the value into #editor before the dom was loaded.

@thenitai
Copy link

Hmmm I've tried that. Do you have an example? Much appreciated. Thx

On Wednesday, April 23, 2014, Manikanta Reddy [email protected]
wrote:

pass the value into #editor before the dom was loaded.


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-41160067
.

See for yourself how easy it is to manage files today. Join the revolution!

Razuna - Hosted Digital Asset Management Solution
http://www.razuna.com/

Razuna - Open Source Digital Asset Management
http://www.razuna.org/

Twitter - http://twitter.com/razunahq
Support Platform - http://forums.razuna.org

@ddmitr
Copy link
Author

ddmitr commented Apr 23, 2014

If I add content before the dom was loaded - it's works fine. But I need add content after...

@manikantareddygk
Copy link

function intiEditor(element) {
$('#wikitext').wysihtml5({
"image": false,
"size": 'sm'
}).html(element.extract);
};

@thenitai
Copy link

Is it only possible to add content to the editor before the dom is loaded? Isn't there an option to change the content on runtime? Thanks.

@Waxolunist
Copy link
Owner

As already suggested:

$('#divORtextarea').val('some text');

should work at any time.

Works for me at least on the latest 0.3.x branch. Which branch are u using?

@thenitai
Copy link

For the live of me, can't get it working. I mean, it works the very first time, but I need to change it on a click of a button. Then it doesn't work anymore. Using latest master branch here as well.

@Waxolunist
Copy link
Owner

Ok, I can now see it. Click on a button does not work with textarea.
If it is possible for you to switch to the 0.3. branch u can use following method with divs.

$('#divORtextarea').html('some text');

That works for me at least. I pushed an example to index-multi-dev.

Waxolunist added a commit that referenced this issue Apr 30, 2014
@thenitai
Copy link

thenitai commented May 1, 2014

We have already been using .html() to set the value. However, it only works the first time (when the page loads). Subsequent tries to set the value of a textarea don't.

The reason for this could be that your branch "0.3.0-wip" doesn't work. Whenever we use ..wysihtml5() we get an error message of Uncaught "TypeError: undefined is not a function". However it works with the master branch.

It could be that we use require.js for loading the scripts?

Really appreciate your endeavours here. Thank you.

@Waxolunist
Copy link
Owner

Have you seen https://github.com/Waxolunist/bootstrap3-wysihtml5-bower/blob/v0.3.0-wip/index-multi-dev.html#L120?

There I copy the value of textarea1 to textarea2 with the click on a button.
Requirejs is only supported with the 0.3.x branch, but if you found a way with the 0.2.x branch, this is ok.
The current branch does not show any problems and I will make the final release soon, so there will be no hard changes anymore.

In the examples section you can see an requirejs example.

@Waxolunist
Copy link
Owner

Ok just found a problem with requirejs for the current master. So I am working on that. Expect an update this weekend. It will work.

@Waxolunist
Copy link
Owner

Can you confirm that the example is working for you? See index-require.html.
If you get an error about Type not defined: Have you tried bower update beforehand?

@thenitai
Copy link

thenitai commented May 2, 2014

Yes index-require.html example works. Looking forward to the update this weekend ;-)

Thank you for your help.

@Waxolunist
Copy link
Owner

Ok, so I will close this for now.

@felixcheruiyot
Copy link

Was this solved? I still cannot set the editor value with any of this options:

    $('#editor').wysihtml5().html('my string');
    $('#editor').wysihtml5().val('my string');
    $('#editor').wysihtml5().text('my string');

Please advice, thanks

@abishekrsrikaanth
Copy link

This works with the below code.

$("#text_area").wysihtml5();
var editorObj = $("#text_area").data('wysihtml5');
var editor = editorObj.editor;
editor.setValue(html_goes_here);

Hope this helps

@mleziva
Copy link

mleziva commented Jan 28, 2015

This does not work using an asp textbox:

$("#text_area").wysihtml5();
var editorObj = $("#text_area").data('wysihtml5');
var editor = editorObj.editor;
editor.setValue(html_goes_here);

It says that the editor is undefined. I have linked the bootstrap3-wysihtml5.all.min, jquery, and bootstrap.js.min.

@knickers
Copy link

Thank you @abishekrsrikaanth you saved my day! Is there any documentation about the methods available on that editor object?

@Waxolunist
Copy link
Owner

Basically it is a version of this one: http://wysihtml.com/

@yuhua-chen
Copy link

Thanks @abishekrsrikaanth ! you saved my day as well. works like a charm.

@pacozaa
Copy link

pacozaa commented Jun 14, 2016

Why @abishekrsrikaanth answer is not on readme?

pacozaa added a commit to pacozaa/bootstrap3-wysiwyg that referenced this issue Jun 14, 2016
Edit set text dynamically
according to this issue

Waxolunist/bootstrap3-wysihtml5-bower#45
@gabisajr
Copy link

$('iframe').contents().find('.wysihtml5-editor').html('your new content here');

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