Page 1 of 1

Button class wymupdate

PostPosted: Tue Mar 09, 2010 3:25 am
by joshkraemer
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() {

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


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(;"><span class="sprite mail-send"></span> Send Email</button>

Adding a wymupdate class to the send email button doesn't seem to work.

Re: Button class wymupdate

PostPosted: Mon Mar 29, 2010 5:40 pm
by joshkraemer
Any ideas? I can't seem to get solutions from other similar posts to work.

Re: Button class wymupdate

PostPosted: Wed Mar 31, 2010 9:19 pm
by mr_lundis
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);
// or
var code = wym.xhtml();

Cheers! ;)