Forum closed. New forum available at http://community.wymeditor.org/

AJAX update editor text

Support forum for WYMeditor.

AJAX update editor text

Postby spectral on Tue Dec 18, 2007 7:35 pm

hi,

i'm desperately trying to access the textarea within ajax-requests.

the code (php page):

update_text.php works just fine (as i see when alerting these text values).

Code: Select all
$(document).ready(function() {

   $.ajaxSetup({
      url:   'update_text.php',
      type:   'POST'
   });

   $('.wymeditor').wymeditor({
      html:      "", //doesn't help if omitted / commented out
      preInit:   function(wym) {
         $.ajax({
            data:      {txt:'', action:'init'},
            success:   function(ret) {
               //$('.wymeditor').empty();
               $('.wymeditor').val(ret); //doesn't work
               //alert(ret); //works
               
            }
         });
      },
      postInit:   function(wym) {
         $('.wymupdate').click(function() {
         
            var temp = $('.wymeditor').val();
            
            $.ajax({
               data:      {txt:temp, action:'save_and_load'},
               success:   function(ret) {
                  //alert(ret);
                  $('.wymeditor').val(ret); //doesn't work either
               }
            });
         });
      }
   });
});


the form:

Code: Select all
<form action="#" method="post">
<textarea class="wymeditor"></textarea>
<input type="submit" class="wymupdate" value="update" />
</form>


i tried
Code: Select all
wym.html


Code: Select all
wym.html(ret);
nor
Code: Select all
wym.html = ret;
works



somebody any solutions how to assign the read text values to the editors textarea?


thanks a lot.
spectral
 
Posts: 2
Joined: Tue Dec 18, 2007 7:13 pm

Postby rostr on Wed Dec 19, 2007 9:07 pm

Try something like this:

WYM_INSTANCES[0].xhtml()


I know that's not the right way to do it, but it worked for me.
rostr
 
Posts: 22
Joined: Sun Jun 17, 2007 8:21 pm

Postby spectral on Thu Dec 20, 2007 6:23 pm

rostr wrote:Try something like this:

WYM_INSTANCES[0].xhtml()


I know that's not the right way to do it, but it worked for me.


hi rostr,

first thanks for the tip.

i tried

Code: Select all
WYM_INSTNCES[0].xhtml(ret); //your suggestion

WYM_INSTNCES[0].html(ret); //my aproaches
$(´.wymeditor´).attr(´value´, ret);


all didn´t work for me - editor still blank!


only the
Code: Select all
html
option within the wymeditor setup works, but you can not manipulate it.

there must be a way to solve this arrrghh


take care & bye.
spectral
 
Posts: 2
Joined: Tue Dec 18, 2007 7:13 pm

Postby rostr on Fri Dec 21, 2007 7:59 pm

WYM_INSTNCES[0].xhtml(ret); //your suggestion

WYM_INSTNCES[0].html(ret);


Well, in the above, WYM_INSTANCES is misspelled. Might that be it?[/quote]
rostr
 
Posts: 22
Joined: Sun Jun 17, 2007 8:21 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest