<?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>Monkey Magician &#187; Javascript</title>
	<atom:link href="http://www.monkeymagician.co.uk/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.monkeymagician.co.uk</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 16 Jun 2010 12:14:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Default Event Handlers in MooTools 1.2 Classes</title>
		<link>http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/</link>
		<comments>http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 14:33:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[options]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/</guid>
		<description><![CDATA[I recently started converting some UI components I created in MooTools 1.1 into 1.2 versions to use on a new project. For a point release, I&#8217;m surprised how different a lot of the MooTools syntax is in the latest version. One thing that took a bit of getting used to was how inheritance has changed, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started converting some UI components I created in MooTools 1.1 into 1.2 versions to use on a new project. For a point release, I&#8217;m surprised how different a lot of the MooTools syntax is in the latest version. One thing that took a bit of getting used to was how inheritance has changed, and the knock on effects when using Options and Effects in my classes.<span id="more-12"></span></p>
<p>In the MooTools 1.1 version I had a base class, &#8216;Widget&#8217; which I would extend as below:</p>
<p class="code">var DialogBox = Widget.extend({ &#8230; });</p>
<p>Widget implements both Options and Events which allowed me to create a set of events the widget can fire, handlers for which can be added through options, as such:</p>
<pre class="code">var DialogBox = Widget.extend({
  options : {
    onCancel : this.close.bind(this)
  }
  ...
});</pre>
<p>Because extend is a method of Widget, its &#8216;this&#8217; is the object itself and, provided there is a close method, the event handler for &#8216;cancel&#8217; is set up.</p>
<p>MooTools 1.2 introduces a new syntax for extending objects:</p>
<pre class="code">
var DialogBox = new Class({
  Extends : Widget,

  options : {
    onCancel : this.close.bind(this)
  },
  ...
});</pre>
<p>Now, the &#8216;this&#8217; is actually the window object so the cancel event is actually handled by the window.close method &#8211; not quite the functionality intended!</p>
<p>After digging around in the MooTools code, in particular the Request.HTML class, I found what appears to be the only way to default events in options. By setting the option before calling setOptions (if it isn&#8217;t already set), the event handler is correctly assigned:</p>
<pre class="code">
var DialogBox = new Class({
  Extends : Widget,

  options : {
    ...
  },

  initialize: function(options) {
    options.onCancel = options.onCancel || this.close.bind(this);
    this.setOptions(options);
  },
  ...
});</pre>
<p>The binding is now done on instantiation so the correct close method is assigned as the cancel event handler.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Live Javascript Validation</title>
		<link>http://www.monkeymagician.co.uk/2007/09/05/live-javascript-validation/</link>
		<comments>http://www.monkeymagician.co.uk/2007/09/05/live-javascript-validation/#comments</comments>
		<pubDate>Wed, 05 Sep 2007 14:26:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/?p=5</guid>
		<description><![CDATA[A colleague of mine at Vebra has been working on a very Web 2.0 update of the outdated concepts of JavaScript client-side validation, Live Validation.
Traditionally, JavaScript form validation involves calling a validate function when the onSubmit event of the form is fired, with the function returning whether or not the form validated. In most cases, [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague of mine at <a href="http://www.vebra.info/" rel="external">Vebra</a> has been working on a very Web 2.0 update of the outdated concepts of JavaScript client-side validation, <a href="http://www.livevalidation.com/" rel="external">Live Validation</a>.<span id="more-5"></span></p>
<p>Traditionally, <a href="http://www.w3schools.com/js/js_form_validation.asp" rel="external">JavaScript form validation</a> involves calling a validate function when the onSubmit event of the form is fired, with the function returning whether or not the form validated. In most cases, if validation failed the user is informed; in the best cases with a highlighted field and inline message, in the worst with an alert box.</p>
<p>With recent trends in website / web application development moving towards more responsive pages and the use of Ajax to speed up user interaction, this system has been crying out for a radical update. Until now.</p>
<p><a href="http://www.livevalidation.com/" rel="external">Live Validation</a> allows a developer to hook any number of validation requirements directly onto form elements. As a user interacts with the field they are given real-time feedback as to whether their data is valid.</p>
<p><img src="http://www.monkeymagician.co.uk/wp-content/uploads/2008/01/livevalidation1.png" alt="Live Validation" class="border" /></p>
<p>The open-source library is available for download to work either with the Prototype framework or as a stand-alone version. The Prototype version integrates well with Ruby on Rails applications and the coding conventions of Live Validation will be very familiar to Rails developers but simple enough to be understood by anyone with basic JavaScript knowledge.</p>
<p>Once the library is downloaded and included on your page, adding validation couldn&#8217;t be much easier. The LiveValidation object is instantiated with an id of (or reference to) the input element and then rules added to the object. The following example validates for a required field with an id of &#8216;f1&#8242;:</p>
<p class="code">var f1 = new LiveValidation(&#8216;f1&#8242;);<br />
f1.add(Validate.Presence);</p>
<p>LiveValidation also allows chaining of rules and even the object so that it is possible to simply have a single line of code provide very powerful validation rules. The example below requires the field to be filled and to be numeric:</p>
<p class="code">new LiveValidation(&#8216;f1&#8242;).add(Validate.Presence).add(Validate.Numericality);</p>
<p>The range of validation rules doesn&#8217;t end with required fields and numbers, Live Validation also covers regular expression pattern matching, numeric ranges, length ranges and inclusion / exclusion, amongst others.</p>
<p>Overall, Live Validation&#8217;s powerful features, simplicity of use and extensive on-line documentation, combined with it&#8217;s graceful degradation and real-time user interaction add up to provide a fantastic replacement for an ageing concept.</p>
<p class="update"><em>Update: Since writing the article there have been two point-releases of LiveValidation and it is now on version 1.2. Added is support for select boxes, time delayed checking and automatic onSubmit validation. Full details are available on <a href="http://www.livevalidation.com/blog" rel="external">the blog</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2007/09/05/live-javascript-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
