<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>matthewkenny.com &#187; textbox</title>
	<atom:link href="http://www.matthewkenny.com/tag/textbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matthewkenny.com</link>
	<description></description>
	<lastBuildDate>Sun, 20 Dec 2009 23:10:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>TinyMCE and jQuery validation</title>
		<link>http://www.matthewkenny.com/2009/05/tinymce-and-jquery-validation/</link>
		<comments>http://www.matthewkenny.com/2009/05/tinymce-and-jquery-validation/#comments</comments>
		<pubDate>Thu, 07 May 2009 07:19:58 +0000</pubDate>
		<dc:creator>Matthew Kenny</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[textarea]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[tinyMCE]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.matthewkenny.com/?p=41</guid>
		<description><![CDATA[I&#8217;ve recently been working on a project using the ASP.Net MVC framework (more on that in a later post perhaps), where the TinyMCE editor was used as the rich text input method of choice. We hit a snag when it came to applying client-side validation through jQuery: jQuery was validating the textarea before TinyMCE was [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently been working on a project using the ASP.Net MVC framework (more on that in a later post perhaps), where the TinyMCE editor was used as the rich text input method of choice.  We hit a snag when it came to applying client-side validation through jQuery: jQuery was validating the <tt>textarea</tt> before TinyMCE was filling it in with the editor content.<br />
<span id="more-41"></span><br />
A quick search for &#8216;<tt>TinyMCE jQuery validation</tt>&#8216; turned up a <em>very</em> helpful article by Rebecca Murphy (<a title="jQuery validation and TinyMCE" href="http://blog.rebeccamurphey.com/2009/01/12/jquery-validation-and-tinymce/" target="_blank">link</a>).  This was a godsend for us, as we were worried about having to either scrap TinyMCE or have no client-side validation for any rich text boxes (the horror).  However, it wasn&#8217;t quite what we needed.  We had a page that contained a number of TinyMCE boxes, so we needed to make sure that each one would be properly updated when its associated form submit button was pressed.</p>
<p>Fortunately, after my own trip to the TinyMCE API, I spotted the <tt>init_instance_callback</tt> option, which allowed a function to be called upon the creation of a new editor.  Perfect.  The initial version of the code is below, hopefully if anyone else finds themselves in a tight spot, it might help them out.</p>
<pre name="code" class="javascript">tinyMCE.init({
    mode : 'textareas',
    theme : 'advanced',
    theme_advanced_buttons1 : 'bold,italic,underline',
    theme_advanced_buttons2 : '',
    theme_advanced_buttons3 : '',
    theme_advanced_toolbar_location : 'top',
    theme_advanced_toolbar_align : 'left',
    theme_advanced_statusbar_location : 'bottom',
    init_instance_callback : "initialiseInstance"
});

function initialiseInstance(editor)
{
    //Get the textarea
    var container = $('#' + editor.editorId);

    //Get the form submit buttons for the textarea
    $(editor.formElement).find("input[type=submit]").click(
        function(event)
        {
            container.val(editor.getContent());
        }
    );
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewkenny.com/2009/05/tinymce-and-jquery-validation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
