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

Button class wymupdate

Support forum for WYMeditor.

Button class wymupdate

Postby joshkraemer on Tue Mar 09, 2010 3:25 am

Maybe I've missed something here, but how do I get WYMeditor to submit the contents of the textarea when using ajax and <button> instead of a submit button?:

<head> JS

Code: Select all
   jQuery(function() {
      jQuery('.wymeditor').wymeditor();
   });

function dosendemail()
{
   $return = confirm('Are you sure to send the Email?');
   if($return)
   {
      new Ajax.Updater('Mailmessage','<?php echo $this->base; ?>/applications/sendemail', {asynchronous:true, evalScripts:true, onComplete:function(request) {Element.hide('loading');}, onLoading:function(request) {Element.show('loading');}, parameters:Form.serialize('frmsendemail'), requestHeaders:['X-Update', 'Mailmessage']});
   }
}


<body>

Code: Select all
<form action="#" method="post" name="frmsendemail" id="frmsendemail">
<input type="text" value="Email Subject" />
<textarea class="wymeditor code required"></textarea>
<button type="button" class="wymupdate big left"  id="sendemail" onClick="validatesendemail(this.form.name);"><span class="sprite mail-send"></span> Send Email</button>
</form>


Adding a wymupdate class to the send email button doesn't seem to work.
joshkraemer
 
Posts: 5
Joined: Mon Apr 20, 2009 3:28 am

Re: Button class wymupdate

Postby joshkraemer on Mon Mar 29, 2010 5:40 pm

Any ideas? I can't seem to get solutions from other similar posts to work.
joshkraemer
 
Posts: 5
Joined: Mon Apr 20, 2009 3:28 am

Re: Button class wymupdate

Postby mr_lundis on Wed Mar 31, 2010 9:19 pm

Hi!
The WYMeditor click event listener is most likely firing after your event listener, thus WYMeditor updates the textarea after your AJAX-request is sent. You could either force WYMeditor to update the textarea directly using the update() method or get the generated code directly using the xhtml() method.

Code: Select all
var wym = $.wymeditors(0);
wym.update();
// or
var code = wym.xhtml();


Cheers! ;)
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests