Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the contents of a nicEdit form when submitting trough ajax?

So what I want to do is to submit a form using jQuery's AJAX function. And the route I choose to go was to use $('#form').serialize(); and then pass that as a GET request. It works out all dandy and fine and dandy until I add the editor, NicEdit, that I'm going to use on the site.

I've researched the issue and the situation is so that once NicEdit takes over a text-area for example, it hides the text-area to the user and instead has her write into a . This data will then be put back into the text-area triggered by the push of a normal submit button.

Now the issue is: I don't have a normal submit button and hence don't trigger the event that puts the data back in the text-area. And I have tried my best to solve the issue google a solution but everything I've found has been worthless.

Given the fallowing basic setup of my situation: http://jsfiddle.net/MMzhS/1/ - How would you get the data from the NicEdit form to the text-area before alert(); is called?

like image 889
Rovanion Avatar asked Mar 05 '11 23:03

Rovanion


2 Answers

var nicE = new nicEditors.findEditor('assignment');
question = nicE.getContent();

'assignment' is your textarea id.

the textarea content is save on question variable, hope this will help

like image 79
Sunu Pinasthika Fajar Avatar answered Nov 08 '22 08:11

Sunu Pinasthika Fajar


The following as provided by BinaryKitten from #jQuery does the same but a bit cleaner in my opinion: http://jsfiddle.net/MMzhS/5/

like image 34
Rovanion Avatar answered Nov 08 '22 09:11

Rovanion