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?
Create a nicEdit instance
MyApp.editor = new nicEditor().panelInstance('texarea_id');
Let the user enter content to their heart's content! (Pun unintended)
Get the content:
var content = MyApp.editor.instanceById('textarea_id').getContent();
Post the content as usual using
content
.var nicInstance = nicEditors.findEditor('options1'); var messageContent = nicInstance.getContent();
where options1 is id of textarea
'assignment' is your textarea id.
the textarea content is save on question variable, hope this will help
The following as provided by BinaryKitten from #jQuery does the same but a bit cleaner in my opinion: http://jsfiddle.net/MMzhS/5/
is the data's information. Also, please use
$.post
instead of$.get
for form submissions; be nice to the internet.for people who are wondering how to add a custom combobox in nicEdit, here is my blog post to display a custom dropdown with dynamic values
Link
Through editing NiceEdit js file we can add custom Combo box in NicEdit
Through Following way we can add dropdown or combobox to NicEdit. You can get dropdown value from database through ajax call and show it in NicEdit First of all download and implement NicEdit on aspx page Download the NiceEdit js file and you can enable it by following code (http://nicedit.com/)
Now add getddlData() Ajax function in niceEdit.js file in the end of the file
// Add a webMethod in codebehind (.cs file) to fetech dropdown value into nicedit
Now open NicEdit js file and copy (Line no 1552) or search following line:
Got to line no 1230 or search following line:
var nicSelectOptions = { buttons: { Add following below fontFormat function
'CustomBookmark': { name: __('Insert Bookmark'), type: 'nicEditorInsertBookmark', // command: 'InsertBookmark' //InsertBookmark }
now updated function should look like this
Now goto line 1385 or update: function (A) { Change it to
On DropDown options click This will add Drop down value in text Editor on cursor position.
END, you should able to see results