[ 2 posts ]

Christopher Austin

  • Username: cripaustin
  • Joined: Fri May 18, 2012 12:44 am
  • Posts: 2
  • Offline
  • Profile

Post HTML with Rich Text Editor

Post Posted: Fri May 18, 2012 12:51 am
+0-
Hi

I have used the YUI 2 Rich Text Editor on my website but I am having trouble _POSTing the html (from the form) to my handle page.

I am still learning Javascript and it is not so strong at the moment but I need to solve this one problem.

I read on the tutorial that I should use this code:

var myEditor = new YAHOO.widget.Editor('msgpost');
myEditor.render();

//Inside an event handler after the Editor is rendered
YAHOO.util.Event.on('somebutton', 'click', function() {
//Put the HTML back into the text area
myEditor.saveHTML();

//The var html will now have the contents of the textarea
var html = myEditor.get('element').value;
});

but to be honest I don't really understand this - and still don't know how to put the html into the post.

I tried a hidden form input with the value of html but this was unsuccessful.

Can somebody please help?

Thanks!

Chris

Dav Glass

  • Username: davglass
  • Joined: Thu Aug 28, 2008 9:28 am
  • Posts: 2088
  • Location: Marion, IL, US
  • Twitter: davglass
  • GitHub: davglass
  • Gists: davglass
  • IRC: davglass
  • Offline
  • Profile
Tags:

Re: Post HTML with Rich Text Editor

Post Posted: Wed May 23, 2012 6:43 am
+0-
Chris --

When you call `myEditor.saveHTML()` that will filter the HTML inside the Editor and place it back into the textarea that the Editor was rendered from.

If you want that to happen "auto-magically" you should add the `handleSubmit` config option to true when creating the Editor:

Code:
var myEditor = new YAHOO.widget.Editor('msgpost', {
      handleSubmit: true
});
myEditor.render();
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum