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

jQuery post and serialize

Support forum for WYMeditor.

jQuery post and serialize

Postby oraknabo on Tue Feb 17, 2009 12:41 am

I'm trying to post a form with an instance of the editor through the jQuery post() function and I'm using serialize. I tried to do them as separate functions, but the textarea doesn't ever update before serialize happens. This is a really basic example of what I'm talking about:
Code: Select all
$('#comments_form .wymeditor').wymeditor({
   updateSelector: "#comment_sub",
   updateEvent:    "click"
});
$("#comment_sub").click(function(){
    alert($("#comments_form").serialize());
    return false;
});

Is there an option I can add to .wymeditor() that would run a function after update?

I know there are ways to attach custom functions to preInit() and postinit(), but I don't see any way to make the editor run a function when the updateEvent happens. Is there a way to do this?
oraknabo
 
Posts: 8
Joined: Tue Feb 17, 2009 12:04 am

Re: jQuery post and serialize

Postby oraknabo on Thu Feb 19, 2009 5:25 pm

Is it me or is the only kind of response on this board lately spam posts?

You guys might want to require email verification on this forum in the future. The captcha alone doesn't seem to be cutting it.
oraknabo
 
Posts: 8
Joined: Tue Feb 17, 2009 12:04 am

Re: jQuery post and serialize

Postby mr_lundis on Fri Feb 20, 2009 4:43 pm

Hi again!

Take a look at the xhtml instance method, it'll return the cleaned up editor content.
Code: Select all
jQuery.wymeditors(0).xhtml();

https://trac.wymeditor.org/trac/wiki/0.5/API#xhtml

And, yeah, we've had some trouble with spam lately. I'll try to look in to it as soon as I get some time over.

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

Re: jQuery post and serialize

Postby oraknabo on Mon Feb 23, 2009 4:44 pm

Thanks, I needed the whole form to serialize at once, so .xhtml() wasn't an option, but after looking at the API, I realized that running $.wymeditors(0).update(); before serialize in the second function does the trick.

The only problem I ran into and I don't really understand this, is that any time I made an AJAX call on the page it locked in the value of $.wymeditors(0).xhtml(); to the time the call was made. Any changes in the editor after the call weren't registered by $.wymeditors(0).xhtml(); or $.wymeditors(0).update();

I decided just to go with posting the editor contents through an iframe instead of using serialize, but it's not really the solution I was hoping for.
oraknabo
 
Posts: 8
Joined: Tue Feb 17, 2009 12:04 am

Re: jQuery post and serialize

Postby mr_lundis on Mon Feb 23, 2009 7:12 pm

Using the update method is a much better idea. I replied in a bit of a hurry last time, so I guessed I missed it.

Regarding the issues you experienced, I have no idea of what's causing them. To the best of my knowledge there's no internal locking mechanism inside WYMeditor nor jQuery.

I'm glad you got things working in the end though, 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