mudge (owner)

Revisions

gist: 221616 Download_button fork
public
Description:
A simple rich text editor with jQuery and iframe designMode.
Public Clone URL: git://gist.github.com/221616.git
Embed All Files: show embed
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
* A very basic rich text editor using jQuery and iframe designMode.
*
* In your HTML...
* <input type="hidden" id="article_body" name="article[body]">
* <iframe id="paste"></iframe>
*/
 
/*
* NOTE: The order of these two commands is very important.
* https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8
*/
$('#paste').contents().find('body').html($('#article_body').val());
$('#paste').contents().attr('designMode', 'on');
 
/* Copy the contents of the iframe into the form. */
$('form').submit(function() {
  $('#article_body').val($('#paste').contents().find('body').html());
});