Jwysiwyg Using current textarea value as source content

I am using jwysiwyg for several text areas on one page. However, my text box has initial pre-populated values ​​that I need to use. Instead, jwysiwyg uses the default "Original Content".

my code is:

$(document).ready(function(){ $('textarea').wysiwyg({ autoGrow:true, initialContent: this.value, controls:"bold,italic,underline,|,undo,redo" }); }); 

Evaluate that I could call each text field individually an identifier, but for him it looks like lines of code. Think that my problem boils down to how I refer to "this.value", but can't figure it out.

I can solve this by changing the following in jswysywig.js 'initialContent = original.val ();' change to 'options.initialContent = original.val ();'

+4
source share
2 answers

This is what you are looking for: http://jsfiddle.net/QjBh4/

Hope this fits your needs :))

PS - Please feel free to use my demo version and create your own problem, I will try to help you if I miss something!

Script source et. and etc.

  <link rel="stylesheet" type="text/css" href="http://akzhan.github.com/jwysiwyg/help/lib/blueprint/screen.css" media="screen, projection" /> <link rel="stylesheet" type="text/css" href="http://akzhan.github.com/jwysiwyg/help/lib/blueprint/print.css" media="print" /> <link rel="stylesheet" href="http://akzhan.github.com/jwysiwyg/jquery.wysiwyg.css" type="text/css"/> <script type="text/javascript" src="http://akzhan.github.com/jwysiwyg/jquery.wysiwyg.js"></script> <script type="text/javascript" src="http://akzhan.github.com/jwysiwyg/controls/wysiwyg.image.js"></script> 

Code example

 (function($) { $(document).ready(function() { $('textarea').each(function() { value_of_textarea = this.value; $(this).wysiwyg({ autoGrow: true, initialContent: function() { return value_of_textarea; }, controls: "bold,italic,underline,|,undo,redo" }); }); }); })(jQuery);​ 
+3
source

In my case, I made a stupid mistake. value="whatever" not a textarea attribute. The only reason I post this is, I assume that other people made the same mistake due to the number of results on Google for this problem. It may have been a real bug in jWysiwyg at some point, but it works for me (without any changes) should work with v0.97

<textarea id="wysiwyg" rows="10" cols="80" wrap="physical" name="whatever">This is your initial content.</textarea>

0
source

Source: https://habr.com/ru/post/1442580/


All Articles