<?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>cakebaker &#187; javascript</title>
	<atom:link href="http://cakebaker.42dh.com/tags/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Mon, 19 Jul 2010 14:23:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Grouping &#8220;constants&#8221; with JavaScript</title>
		<link>http://cakebaker.42dh.com/2010/07/14/grouping-constants-with-javascript/</link>
		<comments>http://cakebaker.42dh.com/2010/07/14/grouping-constants-with-javascript/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 14:10:32 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/?p=1427</guid>
		<description><![CDATA[A while ago I wrote about how you can group related constants in PHP5 by using a constants class: class MyConstants { const AA = 'value'; const BB = 'another value'; } echo MyConstants::AA; // output: value Now, while experimenting with JavaScript (or more precisely with Node.js) I got some constants in my code I [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I wrote about how you can <a href="http://cakebaker.42dh.com/2008/10/09/grouping-of-constants/">group related constants</a> in PHP5 by using a constants class:</p>
<pre>
<code>class MyConstants {
    const AA = 'value';
    const BB = 'another value';
}

echo MyConstants::AA; // output: value</code>
</pre>
<p>Now, while experimenting with JavaScript (or more precisely with <a href="http://nodejs.org">Node.js</a>) I got some constants in my code I wanted to organize with such a constants class. My first, albeit naive, approach looked like:</p>
<pre>
<code>var sys = require('sys');

function MyConstants() {
    const AA = 'value';
    const BB = 'another value';
}

sys.puts(MyConstants.AA); // output: undefined</code>
</pre>
<p>However, as you can see, this doesn&#8217;t work. One reason is that <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/const">const</a> &#8220;[c]reates a constant that can be global or local to the function in which it is declared.&#8221;. So it isn&#8217;t possible to create a constants class like I imagined&#8230;</p>
<p>This means we have to emulate a constants class by using static properties and relying on the naming convention that names of constants are uppercased (i.e. the &#8220;constants&#8221; are technically not constants and their value can be changed):</p>
<pre>
<code>var sys = require('sys');

function MyConstants() {
}

MyConstants.AA = 'value';
MyConstants.BB = 'another value';

sys.puts(MyConstants.AA); // output: value</code>
</pre>
<p>If there is a better approach, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2010/07/14/grouping-constants-with-javascript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Jamal Helper</title>
		<link>http://cakebaker.42dh.com/2007/05/01/jamal-helper/</link>
		<comments>http://cakebaker.42dh.com/2007/05/01/jamal-helper/#comments</comments>
		<pubDate>Tue, 01 May 2007 07:32:50 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[jamal]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/01/jamal-helper/</guid>
		<description><![CDATA[In the last few days I experimented again with the Javascript MVC framework Jamal. To make its usage a bit easier I wrote a simple helper (you can find it in the downloads section). As usual, you have to add the helper to the $helpers array of your controller(s) before you can use it: var [...]]]></description>
			<content:encoded><![CDATA[<p>In the last few days I experimented again with the Javascript MVC framework <a href="http://jamal.moagil.de">Jamal</a>. To make its usage a bit easier I wrote a simple helper (you can find it in the <a href="http://cakebaker.42dh.com/downloads">downloads section</a>).</p>
<p>As usual, you have to add the helper to the $helpers array of your controller(s) before you can use it:</p>
<pre>
var $helpers = array('Jamal');
</pre>
<p>The helper provides two public methods: link() and set(). </p>
<p>The link() method is used in the head section of the layout to include all Jamal-related files. </p>
<pre>
echo $jamal->link();
</pre>
<p>If DEBUG is greater than 0, it creates something like:</p>
<pre>
&lt;script type="text/javascript" src="/js/src/jamal.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/models/example.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/plugins/metadata.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/controllers/examples_controller.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/views/examples.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/src/startup.js"&gt;&lt;/script&gt;
</pre>
<p>As soon as you switch DEBUG to 0, it will include the packed version of your scripts (you have to pack them &#8220;manually&#8221; with the Ant script that comes with Jamal):</p>
<pre>
&lt;script type="text/javascript" src="/js/dist/jamal_packed.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/js/dist/startup.js"&gt;&lt;/script&gt;
</pre>
<p>The second method, set(), is used to specify which (Javascript) controller action is executed when the respective view is loaded. So in the view you will do something like:</p>
<pre>
$jamal-&gt;set('MyController', 'myAction');
</pre>
<p>Additionally, you have to add the variable $jamal_for_layout to the body tag of your layout:</p>
<pre>
&lt;body &lt;?php echo $jamal_for_layout; ?&gt;&gt;
</pre>
<p>This will then generate the following code for Jamal:</p>
<pre>
&gt;body class="jamal {controller:'MyController',action:'myAction',debug:false}"&gt;
</pre>
<p>Happy baking with Jamal :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/05/01/jamal-helper/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MVC with Javascript</title>
		<link>http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/</link>
		<comments>http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/#comments</comments>
		<pubDate>Sat, 17 Mar 2007 14:38:03 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mvc]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/</guid>
		<description><![CDATA[Javascript was one of those things I tried to avoid up to now. I don&#8217;t know why, but somehow I disliked it (probably because it was a pain to use it in the early days of Javascript) ;-) Sure, I used a bit of Ajax here and there, but thanks to the CakePHP Ajax helper [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript was one of those things I tried to avoid up to now. I don&#8217;t know why, but somehow I disliked it (probably because it was a pain to use it in the early days of Javascript) ;-)  Sure, I used a bit of Ajax here and there, but thanks to the CakePHP Ajax helper I didn&#8217;t had to touch the Javascript. </p>
<p>Lately, I decided to do an Ajax application and so I had to learn Javascript. To make my life easier, I decided to use the <a href="http://jquery.com">JQuery framework</a>. I have chosen JQuery over <a href="http://www.prototypejs.org">Prototype</a> because I heard many good things about JQuery, and the API documentation was (and still is) more intuitive. </p>
<p>Of course, my first attempt ended in a total mess. The result looked more like spaghetti than code ;-)  That&#8217;s when I recalled an <a href="http://cakebakery.de/2006/08/17/waschmittel-in-der-kuche/">article</a> (in German) about a Javascript MVC framework called <a href="http://jamal.moagil.de/">Jamal</a>, developed by <a href="http://teemow.com">Timo Derstappen</a>. From the Jamal website:</p>
<blockquote><p>
The MVC concept is easy to adopt for javascript </p>
<ul>
<li>Controller: Interaction with the user interface (events) </li>
<li>Model: Business Logic and AJAX calls </li>
<li>View: DOM, CSS modifications </li>
</ul>
</blockquote>
<p>That makes sense. So I had a closer look at Jamal. It looked nice, but it bothered me that you would have to use a CSS class &#8220;jamal&#8221; in the HTML code to make it work. So I wrote my own implementation called &#8220;jscake&#8221; which avoids that. You can find the first version in the <a href="http://cakebaker.42dh.com/downloads">downloads section</a>.</p>
<p>Let&#8217;s create a simple &#8220;Hello world&#8221; example with jscake. Our example (CakePHP) view will contain a link and a div to show the messages: </p>
<pre>
&lt;a href=""&gt;click&lt;/a&gt;
&lt;div id="messages"&gt;&lt;/div&gt;
</pre>
<p>First we create our model. All models are in the &#8220;$m&#8221; namespace (please correct me if that is the wrong term), which is a shortcut for &#8220;jscake.models&#8221;. So our model is called &#8220;$m.Example&#8221;. The model contains one function to return the text which should be displayed:</p>
<pre>
// app/webroot/js/models/example.js
$m.Example = {

    getText: function() {
        return "hello world";
    }
};
</pre>
<p>The view is similar to the model, it contains only one function, too. In the function the element with the id &#8220;messages&#8221; is located and the text appended to that element. Similar to the models the views are in the &#8220;$v&#8221; namespace.</p>
<pre>
// app/webroot/js/views/examples.js
$v.Examples = {

    showMessage: function(message) {
        $('#messages').append(message);
    }
};
</pre>
<p>Last, but not least, we have to create the controller. The index function is automatically called when the JQuery ready event occurs. In this function we simply say that when someone clicks on the link, the other function of the controller (sayHelloWorld) should be executed.</p>
<pre>
//app/webroot/js/controllers/examples_controller.js
$c.ExamplesController = {

    index: function() {
        $('a').click(this.sayHelloWorld);
    },

    sayHelloWorld: function() {
        $v.Examples.showMessage($m.Example.getText());

        return false;
    }
};
</pre>
<p>To make our example work we have to include all needed Javascript files in our view, with CakePHP 1.2 it looks like:</p>
<pre>
&lt;?php $javascript-&gt;link(array('jquery-1.1.2', 'jscake', 'controllers/examples_controller',
'models/example', 'views/examples', 'start'), false); ?&gt;
&lt;a href=""&gt;click&lt;/a&gt;
&lt;div id="messages"&gt;&lt;/div&gt;
</pre>
<p>Have fun with jscake! Feedback is welcome :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/03/17/mvc-with-javascript/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Referencing Javascript files</title>
		<link>http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/</link>
		<comments>http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/#comments</comments>
		<pubDate>Wed, 21 Feb 2007 16:52:44 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/</guid>
		<description><![CDATA[If you want to use a Javascript file, you usually reference it in the head section of your layout: &#60;head&#62; &#60;?php echo $javascript-&#62;link('script.js'); ?&#62; &#60;/head&#62; But sometimes you want to use a certain Javascript file only in one view. Then it doesn&#8217;t make sense to reference it in the layout. You could take the PHP [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to use a Javascript file, you usually reference it in the head section of your layout:</p>
<pre>
&lt;head&gt;
    &lt;?php echo $javascript-&gt;link('script.js'); ?&gt;
&lt;/head&gt;
</pre>
<p>But sometimes you want to use a certain Javascript file only in one view. Then it doesn&#8217;t make sense to reference it in the layout. You could take the PHP statement from above and place it in your view, that will work. But it is not a clean solution as the Javascript reference is placed somewhere in the middle of the generated HTML code. </p>
<p>Fortunately, CakePHP 1.2 allows you to define a reference to a Javascript file which is then added to the head section of the generated HTML code. For this purpose the variable $scripts_for_layout has to be added to the layout:</p>
<pre>
&lt;head&gt;
    &lt;?php echo $scripts_for_layout; ?&gt;
&lt;/head&gt;
</pre>
<p>In the view you can now link to the Javascript file with: </p>
<pre>
$javascript-&gt;link('script.js', false);
</pre>
<p>That&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/02/21/referencing-javascript-files/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>New projects on CakeForge</title>
		<link>http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/</link>
		<comments>http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/#comments</comments>
		<pubDate>Tue, 12 Sep 2006 09:27:16 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakeforge]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/</guid>
		<description><![CDATA[My latest post about projects on CakeForge was two months ago. Since then several new projects were started. Here a short overview. BehaviourJS Helper: As its name says it is a helper for the Behaviour JavaScript library, a library that allows you to apply JavaScript to your HTML elements by using CSS selectors. There is [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://cakebaker.42dh.com/2006/07/03/five-new-projects-on-cakeforge/">latest post</a> about projects on <a href="http://cakeforge.org">CakeForge</a> was two months ago. Since then several new projects were started. Here a short overview.</p>
<p><strong><a href="http://cakeforge.org/projects/behaviourhelper/">BehaviourJS Helper</a></strong>: As its name says it is a helper for the <a href="http://bennolan.com/behaviour/">Behaviour JavaScript library</a>, a library that allows you to apply JavaScript to your HTML elements by using CSS selectors. There is already a <a href="http://cakeforge.org/frs/?group_id=89&#038;release_id=129">release</a> available.</p>
<p><strong><a href="http://cakeforge.org/projects/minical/">MiniCalendar</a></strong>: The goal of this project is to provide a calendar for CakePHP. </p>
<p><strong><a href="http://cakeforge.org/projects/xmlparser/">XML Parser Component</a></strong>: It is obvious what the goal of that project is: to create an XML parser component. I don&#8217;t know how it will differ from the XML parser that is part of the coming 1.2 version of CakePHP.</p>
<p><strong><a href="http://cakeforge.org/projects/qubix/">Qubix CMS</a></strong>: The goal of this project is to create a CMS for Flash sites.</p>
<p><strong><a href="http://cakeforge.org/projects/capadonna/">Capadonna</a></strong>: This is another Flash project. From the project description: &#8220;CakeAMFPHP / Actionscript Type Mapping System. Client side type mapping system to convert Cake data to and from typed flash objects via CakeAMFPHP remoting.&#8221;</p>
<p><strong><a href="http://cakeforge.org/projects/dojo-helper/">DojoHelper</a></strong>: Another helper for a JavaScript library, this time for the <a href="http://dojotoolkit.org/">Dojo Javascript Toolkit</a>.</p>
<p><strong><a href="http://cakeforge.org/projects/hdcalendar/">hdCalendar Plugin</a></strong>: Another calendar. In contrast to the aforementioned MiniCalendar project there is already some code available (<a href="http://cakeforge.org/frs/?group_id=82">http://cakeforge.org/frs/?group_id=82</a>).</p>
<p><strong><a href="http://cakeforge.org/projects/cakeforum/">CakeForum</a></strong>: The goal of this project is obvious: to create a forum application. </p>
<p>As always, good luck to these developers :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/09/12/new-projects-on-cakeforge/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updating multiple divs with Ajax. Without crashing Firefox</title>
		<link>http://cakebaker.42dh.com/2006/08/18/updating-multiple-divs-with-ajax-without-crashing-firefox/</link>
		<comments>http://cakebaker.42dh.com/2006/08/18/updating-multiple-divs-with-ajax-without-crashing-firefox/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 07:37:57 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=248</guid>
		<description><![CDATA[In an earlier post I showed you how you can update multiple divs with Ajax. But there was one problem: it crashed Firefox on my machine, and other people reported the same problem, whereas it worked for others&#8230; In a comment, Josh Southern, pointed me to the cause of the problem: the &#8220;latest&#8221; version, 1.4, [...]]]></description>
			<content:encoded><![CDATA[<p>In an earlier <a href="http://cakebaker.42dh.com/2006/06/29/how-to-update-multiple-divs-with-ajax/">post</a> I showed you how you can update multiple divs with Ajax. But there was one problem: it crashed Firefox on my machine, and other people reported the same problem, whereas it worked for others&#8230;</p>
<p>In a <a href="http://cakebaker.42dh.com/2006/06/29/how-to-update-multiple-divs-with-ajax/#1356">comment</a>, Josh Southern, pointed me to the cause of the problem: the &#8220;latest&#8221; version, 1.4, of <a href="http://prototype.conio.net/">prototype</a>, the Javascript framework used by CakePHP, caused the problem. After replacing the prototype library with the latest version (1.5.0_rc final) provided with <a href="http://script.aculo.us/">script.aculo.us</a>, the example worked fine with Firefox. Thanks to Josh for the hint!</p>
<p>Update (2006-10-01): Corrected links.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/08/18/updating-multiple-divs-with-ajax-without-crashing-firefox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A simple redirect component</title>
		<link>http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/</link>
		<comments>http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/#comments</comments>
		<pubDate>Tue, 28 Mar 2006 15:11:57 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=153</guid>
		<description><![CDATA[I already wrote about doing a redirect with Ajax. Now, I created a simple component from that code I presented there: // app/controllers/components/redirect.php class RedirectComponent extends Object { var $controller; var $components = array('RequestHandler'); function startup(&#38;$controller) { $this-&#62;controller =&#38; $controller; } function goto($url) { if ($this-&#62;RequestHandler-&#62;isAjax()) { $this-&#62;controller-&#62;set('url', $url); } else { $this-&#62;controller-&#62;redirect($url); } } [...]]]></description>
			<content:encoded><![CDATA[<p>I already wrote about doing a <a href="http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/">redirect with Ajax</a>. Now, I created a simple component from that code I presented there:</p>
<pre>
// app/controllers/components/redirect.php
class RedirectComponent extends Object
{
    var $controller;
    var $components = array('RequestHandler');

    function startup(&amp;$controller)
    {
        $this-&gt;controller =&amp; $controller;
    }

    function goto($url)
    {
        if ($this-&gt;RequestHandler-&gt;isAjax())
        {
            $this-&gt;controller-&gt;set('url', $url);
        }
        else
        {
            $this-&gt;controller-&gt;redirect($url);
        }
    }
}
</pre>
<p>The usage is easy. Add the component to the components array: </p>
<pre>
var $components = array('Redirect');
</pre>
<p>Afterwards you can use it in the following way:</p>
<pre>
$this-&gt;Redirect-&gt;goto('/mycontroller/myaction');
</pre>
<p>Do not forget do add the code snippet to your view which necessary to do the javascript redirect:</p>
<pre>
&lt;?php if (isset($url)) echo $javascript-&gt;codeBlock('window.location = '.json_encode($url)); ?&gt;
</pre>
<p>Update (2006-04-03): Small bug fixed in startup function.<br />
Update (2009-12-05): Using json_encode to prevent a possible javascript injection problem. Thanks to <a href="http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/#comment-141239">pb</a> for the hint.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/03/28/a-simple-redirect-component/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Redirect with Ajax</title>
		<link>http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/</link>
		<comments>http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/#comments</comments>
		<pubDate>Wed, 15 Mar 2006 08:28:23 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=142</guid>
		<description><![CDATA[In my current project I have a login form I want to validate with Ajax. If everything is ok, the user should be redirected to the respective start page. As it seems to be impossible to do the redirect on the server-side (at least to me), I do it on the client-side. I use the [...]]]></description>
			<content:encoded><![CDATA[<p>In my current project I have a login form I want to validate with Ajax. If everything is ok, the user should be redirected to the respective start page. As it seems to be impossible to do the redirect on the server-side (at least to me), I do it on the client-side. I use the following snippet in my view:</p>
<pre>
&lt;div id="login"&gt;
    &lt;?php echo $ajax-&gt;form(array('action' =&gt; '/login'), 'post',
                                              array('update' =&gt; 'login')); ?&gt;
    ...
    &lt;/form&gt;
    &lt;?php if (isset($url)) echo $javascript-&gt;codeBlock('window.location = "'.$url.'"'); ?&gt;
&lt;/div&gt;
</pre>
<p>And in my controller I use the following code:</p>
<pre>
if ($this-&gt;RequestHandler-&gt;isAjax())
{
    $this-&gt;set('url', '/'.$page);
}
else
{
    $this-&gt;redirect($page);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/03/15/redirect-with-ajax/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Let&#8217;s crash Firefox!</title>
		<link>http://cakebaker.42dh.com/2006/01/31/lets-crash-firefox/</link>
		<comments>http://cakebaker.42dh.com/2006/01/31/lets-crash-firefox/#comments</comments>
		<pubDate>Tue, 31 Jan 2006 17:16:10 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[problem]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=88</guid>
		<description><![CDATA[Today I was able to crash Firefox with a very simple JavaScript. That is the JavaScript: &#60;script type="text/javascript"&#62; function sayHello() { alert('hello'); } sayHello(); &#60;/script&#62; Well, that script works as expected if you have it in a &#8220;normal&#8221; view. But it leads to a &#8220;Segmentation fault&#8221; (and therefore to a crash of Firefox) if the [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was able to crash <a href="http://www.mozilla.com/firefox/">Firefox</a> with a very simple JavaScript. That is the JavaScript:</p>
<pre>
&lt;script type="text/javascript"&gt;
function sayHello()
{
    alert('hello');
}
sayHello();
&lt;/script&gt;
</pre>
<p>Well, that script works as expected if you have it in a &#8220;normal&#8221; view. But it leads to a &#8220;Segmentation fault&#8221; (and therefore to a crash of Firefox) if the same script is in a view you return with Ajax. I think the problem is the &#8220;eval&#8221; function of JavaScript as it seems it cannot execute custom functions (I am not a JavaScript expert so that is only a guess). I solved the problem with moving the JavaScript function to the &#8220;normal&#8221; view. So I have in the view I return with Ajax only the call to my function:</p>
<pre>
&lt;script type="text/javascript"&gt;
sayHello();
&lt;/script&gt;
</pre>
<p>That works :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/01/31/lets-crash-firefox/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nice Date-Picker Widget</title>
		<link>http://cakebaker.42dh.com/2006/01/15/nice-date-picker-widget/</link>
		<comments>http://cakebaker.42dh.com/2006/01/15/nice-date-picker-widget/#comments</comments>
		<pubDate>Sun, 15 Jan 2006 13:52:33 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=60</guid>
		<description><![CDATA[frequency decoder presents a nice date-picker widget. At the bottom of the page, there are also links to other useful Javascripts. I especially like the slider control which looks very cool! [via Olle's bookmarks]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.frequency-decoder.com/2005/10/14/unobtrusive-date-picker-widgit/">frequency decoder</a> presents a nice date-picker widget. At the bottom of the page, there are also links to other useful Javascripts. I especially like the <a href="http://www.frequency-decoder.com/2005/09/10/unobtrusive-slider-control">slider control</a> which looks very cool!</p>
<p>[via <a href="http://del.icio.us/olleolleolle">Olle's bookmarks</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/01/15/nice-date-picker-widget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
