<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>DevChix » Javascript/AJAX</title>
	
	<link>http://www.devchix.com</link>
	<description>Boys can't have all the fun</description>
	<pubDate>Sat, 04 Jul 2009 06:18:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/devchix/sLlx" type="application/rss+xml" /><item>
		<title>Using YUI DataTable with Rails</title>
		<link>http://www.devchix.com/2009/02/07/using-yui-datatable-with-rails/</link>
		<comments>http://www.devchix.com/2009/02/07/using-yui-datatable-with-rails/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 23:11:19 +0000</pubDate>
		<dc:creator>sarah g</dc:creator>
		
		<category><![CDATA[Javascript/AJAX]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[dataTable]]></category>

		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=199</guid>
		<description><![CDATA[I am currently working on an Rails app that integrates the YUI dataTable, and in going through the tutorials I noticed they are all assume a PHP back-end. I also saw a number of people asking how to get this to work with a Rails controller, so I thought I&#8217;d write up my experience in [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working on an Rails app that integrates the <a href="http://developer.yahoo.com/yui/datatable/">YUI dataTable</a>, and in going through the tutorials I noticed they are all assume a PHP back-end. I also saw a number of people asking how to get this to work with a Rails controller, so I thought I&#8217;d write up my experience in the hopes that it helps someone else. For basic info about setting up the dataTable, refer to the YUI site, linked above. I&#8217;m also going to try to clarify a few things that I found a bit obscure. </p>
<p>To create a dataTable you have to define a few basic ingredients: </p>
<ol>
<li>A <a href="http://developer.yahoo.com/yui/datasource/">dataSource</a>. This defines where the info in the table comes from, and what format it is returned in. I&#8217;m using JSON. </li>
<li>A schema that you define. This is a part of the dataSource and is essentially a map to your data. The schema tells the table where to find the field values.</li>
<li>An array of column definitions. You supply the name and &#8220;key&#8221; of each column and any additional information, such as whether it is editable (and if so, which editor to use) and how to format the data inside the column if you don&#8217;t want to just spit it out directly. </li>
</ol>
<p>Let&#8217;s start with a dataSource. In this example, we&#8217;re making a table of tasks, so I want to hit my tasks controller to return the data. Standard Rails controller action.  In the code snippet below,  </p>
<ol>
<li> in line 1, I supply a URL (note that the url ends in .json, and in my controller I have a responds_to block which constructs my json response).</li>
<li>  In line 2, I&#8217;m telling the dataSource &#8212; hey, you&#8217;re gonna get some JSON.  </li>
<li>And line 3, is where we define the <span id="schema">responseSchema</span>, which has two critical parts: the <strong>resultsList</strong> and the <strong>fields</strong>.</li>
</ol>
<pre>
  var dataSource = new YAHOO.util.XHRDataSource("/projects/13/elements/21/tasks.json");
  dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
  dataSource.responseSchema = {
   resultsList: "Resources.data",
   fields: [
      {key:"task.id"},
      {key:"task.status"},
      {key:"task.percent_complete"},
      {key:"task.description"},
      {key:"task.due_date", parser:date}
      ]
  }
</pre>
<p>Let me be clear since I got hung up on this a bit. You as the application developer are responsible for two things.  One, constructing your response &#8212; in other words, you can build your JSON response any way you want, with any keys, values and hierarchical structure that make sense (though it will help you to think it through and standardize it, <a href="http://yuiblog.com/blog/2008/10/27/datatable-260-part-two/">Satyam has some good info on that here</a>). And two, telling your dataSource how to navigate your response: i.e. &#8212; where do find what the data you&#8217;re looking for (the needle) in the response (the haystack of JSON)?  This is the schema, the map of your data.<br />
<span id="controller">Controller code that creates my custom JSON</span>:</p>
<pre>
# tasks_controller.rb
def index
 respond_to do |format|
      format.json{
         tasks = []
         @tasks.each do |task|
           task_container = {}
           task_container  = task
           task_container['editable_by_user'] = permission.edit? # some metadata I use
           task_container['deletable_by_user'] = permission.delete?
           task_container['resource_name'] = "task"
           tasks << task_container
        end
        data = {"Resources" => {"data" => tasks}}
        render :json => data.to_json
      }
  end
end
</pre>
<p>And just for fun, here&#8217;s a look at the JSON my controller gives me back when I hit this url &#8216;/projects/13/elements/21/tasks.json&#8217;.<br />
<span id="json">The JSON</span>:</p>
<pre>
{"Resources": {"data": [{"task": {"status": "not_started", "started_on": null, "updated_at": "2009-02-07T22
:03:18Z", "project_id": 13, "percent_complete": null, "high_priority": null, "element_id": 32, "deletable_by_user"
: true, "completed_on": null, "editable_by_user": true, "element_title": "looking good", "id": 50, "created_by_id"
: 7, "resource_name": "task", "description": "Pass the stimulus bill", "assignments": [], "due_date"
: "", "users": [], "resource_url": "/projects/13/elements/32/tasks/50", "due": null, "created_at": "2009-02-07T22
:03:18Z"}}, {"task": {"status": "not_started", "started_on": null, "updated_at": "2009-02-07T22:03:39Z"
, "project_id": 13, "percent_complete": null, "high_priority": null, "element_id": 32, "deletable_by_user"
: true, "completed_on": null, "editable_by_user": true, "element_title": "looking good", "id": 51, "created_by_id"
: 7, "resource_name": "task", "description": "Negotiate without pre-conditions", "assignments": [], "due_date"
: "", "users": [], "resource_url": "/projects/13/elements/32/tasks/51", "due": null, "created_at": "2009-02-07T22
:03:39Z"}}]}}</pre>
<p>So that&#8217;s it! I&#8217;ve defined this JSON array and built it, then returned it from the controller when I get a .json request. </p>
<p>Now that you&#8217;ve seen the response, take another look at the responseSchema (<a href="#schema">you created above</a>) and the two properties that you set:</p>
<ol>
<li>ResultsList. Notice it is set to &#8220;Resources.data&#8221;, which are the JSON keys I used. It uses dot-syntax to point to array of tasks in my json. </li>
<li>Fields.  Again using dot syntax, and having the ResultsList array to navigate through, it can pull the specific values it wants from the list; so &#8216;task.status&#8217;, &#8216;task.started_on&#8217;, etc., will retrieve those values from the response. </li>
</ol>
<p>Make sense? </p>
<p>You are now one step away from being able to see your table. So, create your column definitions, an array of data about each column in the table. This is also where you can specify formatting and editing information (not covered in this article). </p>
<pre>
var columnDefinitions = [
  {key:"task.status",formatter:"formatPriority", sortable:true},
  {key:"task.percent_complete", label:"Percent Complete", sortable:true},
  {key:"task.description", label:"Description"},
  {key:"task.due_date", label:"Due Date", editable:true,sortable: "true",formatter:YAHOO.widget.DataTable.formatDate, editor: new YAHOO.widget.DateCellEditor({resource:'task', updateParams:"task[due]"})}
  ];
</pre>
<p>Notice that each column definition has a key: this key must be accessible in your JSON, AND it must be defined as a field.  </p>
<p>And then you create your table. The first argument is the id of a div on the page to which the table will be attached, the last is an optional configuration hash (pagination, anyone?).  </p>
<pre>
var dataTable = new YAHOO.widget.DataTable("project_tasks", columnDefinitions, dataSource, optionalConfigurationHash);
</pre>
<p>I hope this is helpful to get you started with the YUI dataTable on Rails. I may do further posts on XHR editing of individual cells in a dataTable using Rails.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2009/02/07/using-yui-datatable-with-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting started with YUI’s Connection Manager in Rails and PHP; or “All Happy Families Are Not Alike”</title>
		<link>http://www.devchix.com/2007/02/28/getting-started-with-yui%e2%80%99s-connection-manager-in-rails-and-php-or-all-happy-families-are-not-alike/</link>
		<comments>http://www.devchix.com/2007/02/28/getting-started-with-yui%e2%80%99s-connection-manager-in-rails-and-php-or-all-happy-families-are-not-alike/#comments</comments>
		<pubDate>Thu, 01 Mar 2007 03:38:42 +0000</pubDate>
		<dc:creator>sarah g</dc:creator>
		
		<category><![CDATA[Javascript/AJAX]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.devchix.com/2007/02/28/getting-started-with-yui%e2%80%99s-connection-manager-in-rails-and-php-or-all-happy-families-are-not-alike/</guid>
		<description><![CDATA[This post is geared towards folks who haven&#8217;t done the A part of AJAX before (And I mean the first A, as in Asychronous); are new to Yahoo&#8217;s implementation of the XMLHttpRequest object (The Yahoo! Connection Manager) and would like added information on how that works; or bothThis is not meant to supplant the excellent [...]]]></description>
			<content:encoded><![CDATA[<p>This post is geared towards folks who haven&#8217;t done the A part of AJAX before (And I mean the first A, as in Asychronous); are new to Yahoo&#8217;s implementation of the XMLHttpRequest object (The Yahoo! Connection Manager) and would like added information on how that works; or bothThis is not meant to supplant the <a target="_blank" href="http://developer.yahoo.com/yui/connection/">excellent yui! tutorials</a> which you should read in detail for thorough explanations and examples. What I am adding here are a few examples of using this in the Rails framework and some thoughts on the callback object and scope.</p>
<p>Your &#8220;AJAX&#8221; goals are simple: you want to communicate with your server, get a response back that you can use (or not), do something with that response (or not), and move on. As this is <strong>asynchronous</strong>, you want to do this without reloading your web page. Or, as a client once said to me, referring to certain animated gifs in the upper right-hand corner of certain browsers, without &#8220;making the world spin&#8221;. To this end, Yahoo! has supplied us one line of code:</p>
<pre>var transaction =
YAHOO.util.Connect.asyncRequest(
method, uri, callback, postData);</pre>
<p>or, same line with some data plugged in:</p>
<pre>var transaction =
YAHOO.util.Connect.asyncRequest(
'POST',   'php/post.php', callback,"id=1&#038;old_id=2");</pre>
<p>When I was making the switch from synchronous to a-, it helped me to visualize a standard web form to see how form elements and attributes are translated to an AJAX request. It&#8217;s pretty obvious, but if you need an &#8220;aha!&#8221; moment, the above line is akin to the html form printed below (though unless you&#8217;re one of those people whose definition of interactivity is &#8220;The Monologue&#8221;, do refrain from creating forms with 2 hard-coded hidden inputs and nothing else! :)).</p>
<pre>&lt;form method="post" action="php/post.php"&gt;
&lt;input type="hidden" name="id" value="1" /&gt;
&lt;input type="hidden" name="old_id" value="2" /&gt;
&lt;input type="submit"&gt;
&lt;/form&gt;</pre>
<p>So, excluding a reference to the <strong>callback </strong>for the moment (which is not addressed in this example), that form maps to the Connection Manager call quite simply: method, action (uri), data.  Let&#8217;s look at the arguments required:</p>
<p><strong>method</strong>: the method of the server request (<strong>POST, GET </strong>and others also available).</p>
<p><strong>uri: </strong>  the uri that&#8217;s receiving and processing the data you send (in our example, &#8220;php/post.php&#8221;). YUI&#8217;s examples use php, but, if you&#8217;re using the Connection Manager in a Rails app, it&#8217;s easy to adapt: your argument <strong>uri </strong>might read “/projects/update which would pass the data to the <strong>update method </strong>in <strong>projects_controller.rb</strong>, which would then be able to access the  data through the <strong>params </strong>array, like so:</p>
<pre>def update
@project = Project.find(params[:id])
end</pre>
<p>In php you&#8217;d probably do some type of db query [assume input cleanup and some type of database abstraction layer, such as <a target="_blank" href="http://pear.php.net/package/DB_DataObject/">PEAR/DB_DataObject</a>,  here]</p>
<pre>$project = DB_DataObject::factory('Projects');
$project->get($_POST['id']);</pre>
<p><strong>Callback</strong>: a reference to the callback object you are supplying. This is how everything is handled.  More on that in a minute.</p>
<p><strong>postData</strong>:  the data itself in standard query-string format (&#8221;new=1&#038;old=2&#8243;). NOTE: if you&#8217;re doing a GET transaction, your 4th argument would be <strong>false</strong> and your second argument would include the url and query string, like so:</p>
<pre>“php/post.php?new=1&#038;old=2".</pre>
<p><strong>So, what&#8217;s this </strong><strong>callback</strong>?. In a synchronous transaction, you have the luxury of redrawing the page to process your data (and yes, nothing says luxury like a nice, slow, page reload&#8230;). In an asynchronous transaction you need to essentially &#8220;sneak&#8221; your data back into the page without reloading it. This is where your callback object comes in. It helps you get your data &#8220;in the door&#8221;, so to speak, so your page or application can change in a way that feels seamless to the user but often returns a visible result (changing a div, displaying some text, etc.) and if not a visible result at least a meaningful one (setting the value of a hidden form element, for example). Your callback is responsible for executing actions based on the data retrieved (or the failure to retrieve data) from the uri.  In a standard synchronous form this action might be &#8220;generate an HTML table that displays your database results&#8221;. Or, &#8220;Print a message saying there are no results&#8221;. Of course, you can do anything  you want with your data, that&#8217;s just an example of a fairly common scenario.</p>
<p>Once you&#8217;ve sent  your data to the uri for processing, you need to wait for your response &#8212; without, of course, appearing to wait (save for the ubiquitous web 2.0 spinner you know you&#8217;re dying to try!).  And, of course you want to know if your transaction failed. If you don&#8217;t watch for these things &#8212; “success&#8221; and “failure&#8221; in technical terms &#8212; you&#8217;re not going to be able to make an appropriate decision about what to do next in your app.  So you feed your AJAX request a callback object:  an object that defines functions for what to do in the cases of success and failure. In simplest terms, we&#8217;ve got</p>
<pre>var callback = {
success: handleSuccess,
failure: handleFailure
};</pre>
<p>where “handleSuccess&#8221; and “handleFailure&#8221; are user-defined functions that take the http response object and do stuff with it.</p>
<pre>handleSuccess = function(o){
// cheer! (or process data returned from the server)
}

handleFailure = function(o){
// cry, vow to try again! (or display failure message)
}</pre>
<p>There&#8217;s also the ability to pass <a target="_blank" href="http://developer.yahoo.com/yui/connection/#scope">scope</a>, <a target="_blank" href="http://developer.yahoo.com/yui/connection/#timeout">timeouts, and additional arguments</a> to the callback object. To do so you&#8217;d read the great tutorials at the links above and add the lines below, of course changing the values to values meaningful in your application.</p>
<pre>scope: Ajaxobject,
timeout: 5000,
args: ['arg1', 'arg2']</pre>
<p><strong>The handlers</strong>. handleSuccess and handleFailure both take an object <strong>o</strong>, which is the http response object. There&#8217;s a detailed list of all the <a target="_blank" href="http://developer.yahoo.com/yui/connection/#success">properties of <strong>o</strong></a> on the yui page (Not to be confused with the <em>Story of O</em>, which I will not link to as it is beyond the scope of this article, you dirty rascals, you&#8230;).  The property you&#8217;ll likely use most often is <strong>o.responseText</strong>, which is the server&#8217;s response as a string.  This is what you pass back from good old &#8216;php/post.php&#8217;, and getting it is simple: echo. What? echo. What? echo..o..o&#8230; ok, sorry, moving on. For instance, if we wanted to capture the update_date in our successHandler to print to  our page and we&#8217;re using php, we&#8217;d write something like this:</p>
<pre>echo $project->update_date;</pre>
<p>and if we&#8217;re in Rails? something like this:</p>
<pre>render_text @project.update_date</pre>
<p>If you need more data than a string &#8212; an array or collection of objects  passed back from the server, you&#8217;ll find that&#8217;s simple, too: call the ruby method <strong>to_json()</strong> on your array instead. This essentially serializes your object so it can survive the journey to the Client. Once there, you can access the data using JavaScript&#8217;s magic wand: eval().  It&#8217;s great.  So if you had an array of users connected to a project (and your database relationships are set up correctly), you could write</p>
<pre>render_text @project.users.to_json</pre>
<p>in php, assume you&#8217;ve got your $users array, and use print_r</p>
<pre>print_r($users);</pre>
<p>The in your JavaScript successHandler use eval(), like so:</p>
<pre>var users =  eval(o.responseText)</pre>
<p>and bingo: in two lines you&#8217;re happily in your JavaScript parsing your users array like you would any other JavaScript array. You have connected your server to your DOM and no one is the wiser for it.</p>
<p>All this is great.  We have our AJAX call and our callback object and are ready to go.  But, suppose you don&#8217;t want to rewrite the AJAX call all over your app?  The Yahoo folks have a great example of a &#8216;“hypothetical ajax object&#8221; (mysteriously named &#8220;AjaxObject&#8221;)  that encapsulates success, failure, and process methods and calls a callback object that defines AjaxObject as it&#8217;s scope. Encapsulating your AJAX request so you can call it from wherever you want in your scripts in a DRY fashion makes your code cleaner and easier to manage. Yahoo! does this well in their example: in my usage I changed it up a little bit to meet my needs.</p>
<p>To quote the great Chicago writer Leo Tolstoy from his famous novel <em>Anna Karenina Does Lake Michigan</em>, &#8216;“Happy families are all alike; every unhappy family is unhappy in its own way&#8221;.     I&#8217;ve learned that when working on an app, the opposite is true: success cases call for a range of actions: failures can more easily handled (log, display error, abort).  Based on this, I&#8217;ve adapted the yui AjaxObject example to accept a postAction, successHandler, and object (used to define scope). This allows you to call AjaxObject from other objects, pass specific success handlers, and pass <strong>this </strong>(a reference to your current object) so you can access it in your successHandler from within the calling object. The AjaxObject builds the callback using those arguments.  Like so:</p>
<pre>var AjaxObject = {

handleFailure:function(o){
// Fail gracefully
},

/**
* Wrapper for AJAX calls using YUI connector
*
* @param postAction {String} URL to post to
* @param callBackSuccess {String} Success handler
* @param postData {String} Data to post
* @param obj {Object} Object that handler has scope in
*
*/
startRequest:function(postAction, callBackSuccess, postData, obj) {

var callback = {
success:callBackSuccess,
failure:this.handleFailure,
scope:obj
}
// ASSUME you've shortened your yui connection mgr to $C
$C('POST', postAction, callback, postData);
}

};</pre>
<p>Then you can call AjaxObject from within a class, like so, and pass it a class method as it&#8217;s success-handler:</p>
<pre>var Project = function Project(){
// initialize project however you like
this.foo = "bar";
...
// CREATE in db and return id
AjaxObject.startRequest('/project/create',
this._generateDbId, postData, this);

}   // Success handler  Project.prototype._generateDbId = function(o){
if(o.responseText !== undefined){
this._setDbid(Number(o.responseText));
// DO other stuff..
}
}</pre>
<p>This way your AJAX calls are in one place, you can use them in the scope of the calling object and define as many success handlers as success cases (or pass false); and fail in one standard way (gracefully, of course). Of course, this can be adapted to pass failure cases in too, or however you like. This was a way I found helpful in my work, and I hope it&#8217;s helpful to you as well.  And thanks again to the folks at Yahoo! for providing so much great stuff to work with in the first place.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2007/02/28/getting-started-with-yui%e2%80%99s-connection-manager-in-rails-and-php-or-all-happy-families-are-not-alike/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A brief look at Yahoo! Event Utility [addListener]</title>
		<link>http://www.devchix.com/2007/02/13/a-brief-look-at-yahoo-event-utility-addlistener/</link>
		<comments>http://www.devchix.com/2007/02/13/a-brief-look-at-yahoo-event-utility-addlistener/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 18:01:39 +0000</pubDate>
		<dc:creator>sarah g</dc:creator>
		
		<category><![CDATA[Javascript/AJAX]]></category>

		<category><![CDATA[Languages]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=24</guid>
		<description><![CDATA[I&#8217;ve been getting familiar with the Event Utility in the Yahoo library , and it&#8217;s a great way to handle and manage javascript events in a clean centralized way. It also smooths out the differences between browser event handling so you no longer need lines like this in your event functions:
e  = e ? [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been getting familiar with the <a target="_new" href="http://developer.yahoo.com/yui/event/">Event Utility in the Yahoo library </a>, and it&#8217;s a great way to handle and manage javascript events in a clean centralized way. It also smooths out the differences between browser event handling so you no longer need lines like this in your event functions:</p>
<pre>e  = e ? window.event;</pre>
<p>If you&#8217;re unfamiliar with events, it might help to read the article on <a target="_new" href="http://www.quirksmode.org/js/introevents.html">quirksmode</a>, as well as the yui page.</p>
<p>This library has lots of great methods for event listening, creating custom events, passing objects to event handler functions (a great feature), stopping default event behavior, and attaching listeners to all elements of a particular class rather than cluttering up your code with hundreds of individual listener calls. It&#8217;s all encapsulated in neat, well-documented code and a clear API.</p>
<p>One current simple example. I&#8217;m building a project where there&#8217;s a text input field on stage that serves as a quick &#8220;editor&#8221;: the user types a number into the field that corresponds with an object on the stage, and then they hit ENTER. [Result: they land in the object in an open editor, saving them mouse-action on the stage and allowing for easy keyboard access to dispersed elements].   We&#8217;re not actually submitting a form and since the text area is embedded in another form we just want to listen for the ENTER key but disable form submission, which automatically happens on enter.  We also need to make sure that if the user double-clicks within the text area, the usual dblclick behavior (which creates a new object) is disabled.  So we want this editor to listen for two events: keydown and dblclick; as well as stop the default behavior of the enter key (submitting the form).</p>
<p>Instead of something like this [pseudo-but-close code]:</p>
<pre>< input type="text" id="editor"
onkeydown="javascript:edit();return false"</pre>
<pre>ondblclick="javascript:return false;" /></pre>
<p>We can simply write</p>
<pre>< input type="text" id="editor" /></pre>
<p>And then in script tags in a centralized location,</p>
<pre>$E = YAHOO.util.Event;</pre>
<pre>$E.addListener('editor', 'keydown', edit);
$E.addListener('editor', 'dblclick', interceptAction);</pre>
<p>The first argument is name of the id of the element in question (or an element object itself); the second is the javascript event to listen for; and the third is the name of your function. There&#8217;s an optional 4th argument, obj, which is an arbitrary object you can pass to your handler. If you do this, define your handler with two arguments: (e,obj).</p>
<p>Then define your functions:</p>
<pre>/* handler to open your editor */</pre>
<pre>var edit = function(e){
// GRAB enter key
if( e.keyCode == 13){
// PREVENT form from submitting on enter
//[the default behavior of the enter key]
$E.preventDefault(e);
// DO things here
openInlineEditor();
}
}</pre>
<pre>/* handler to prevent default actions */
var interceptAction= function(e) {</pre>
<pre>// STOP the event from propagating to other listeners
$E.stopPropagation(e);
}</pre>
<p>This is just the tip of the iceberg. I recommend reading up on this and looking at their examples and related articles linked on the page. It&#8217;s made my event handling easier and  more fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2007/02/13/a-brief-look-at-yahoo-event-utility-addlistener/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CSS Debugging and Editing with Firebug</title>
		<link>http://www.devchix.com/2007/02/12/css-debugging-and-editing-with-firebug/</link>
		<comments>http://www.devchix.com/2007/02/12/css-debugging-and-editing-with-firebug/#comments</comments>
		<pubDate>Mon, 12 Feb 2007 22:00:32 +0000</pubDate>
		<dc:creator>jen</dc:creator>
		
		<category><![CDATA[Javascript/AJAX]]></category>

		<category><![CDATA[Languages]]></category>

		<category><![CDATA[Reviews]]></category>

		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=23</guid>
		<description><![CDATA[Occasionally a new tool  comes along that literally changes my life.   Prototype, del.iciou.us, and most recently, Firebug.  Using it, especially when evaluating CSS and javascript (especially when it&#8217;s all over!), has increased my productivity and saved me from many migraines.  In this post, I plan to focus on some of [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally a new tool  comes along that literally changes my life.   <a href="http://www.prototypejs.org/">Prototype</a>, <a href="http://del.icio.us/">del.iciou.us</a>, and most recently, <a href="http://www.getfirebug.com/">Firebug</a>.  Using it, especially when evaluating CSS and javascript (especially when it&#8217;s all over!), has increased my productivity and saved me from many migraines.  In this post, I plan to focus on some of the helpful features for debugging CSS. In a later post, I plan to cover how wonderful it is to debug and test javascript in firebug,</p>
<p>Especially on websites that have a lot of nested styles, finding where that extra padding is coming from can be a headache and waste a lot of time that could be spent being productive.  With firebug, you can quickly see where each element is getting its styles and the full cascade of styles affecting it.  From there, it is easy to alter the CSS and html live to figure out what needs to be done for the desired effect.  This feature can be used for a world of uses.  For example, say I wanted to override some of the CSS on my orkut.com profile.  First, I open up my profile and open firebug:</p>
<p><a href="http://devchix.com/images/jen/firebug1.jpg"><img border="0" src="http://devchix.com/images/jen/firebug1_thumb.jpg" /></a></p>
<p>The green check mark in the bottom right indicates that there are no errors (you can choose to display any or all of the following: javascript Errors, javascript warnings, CSS errors,  or xml Errors) used on the page is valid.  The dropdown list displays where styles are being defined.</p>
<p><a href="http://devchix.com/images/jen/firebug2.jpg"><img border="0" src="http://devchix.com/images/jen/firebug2_thumb.jpg" /></a></p>
<p>Select &#8220;inspect&#8221; from the menu then  hover to select the element to edit.  On the right hand column, the styles are  defined specifically for the element, but also what it inherits (font from  panel table) and what is over-written (font from main table class).  Dreamweaver 8 has a similar feature for showing the cascade of elements. As an added benefit, each of the rules listed has a hyperlink back to the file where it is defined.  Also in this screen shot,  notice  that firebug displays the html hierarchy as a breadcrumb like chooser for the currently selected element.  This breadcrumb is clickable and allows for quick access to the nearby html elements.</p>
<p><a href="http://devchix.com/images/jen/firebug3.jpg"><img border="0" align="left" style="margin: 15px" src="http://devchix.com/images/jen/firebug3_thumb.jpg" /></a>Here you can see how easy it is to work with or turn off styles.  One great feature displayed in this screenshot is that when hovering over a defined color, a pop-up displays the color.  The same is true for any images that are used in a style or in html.</p>
<p>And, viola!  In only a few short minutes, I am able to find and define what style classes I want to override and see what the page will look like live as I made the adjustments:</p>
<p><a href="http://devchix.com/images/jen/firebug5.jpg"><img border="0" src="http://devchix.com/images/jen/firebug5_thumb.jpg" /></a></p>
<p><br clear="all" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2007/02/12/css-debugging-and-editing-with-firebug/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book Review: Beginning Ajax with PHP by Lee Babin</title>
		<link>http://www.devchix.com/2006/12/13/book-review-beginning-ajax-with-php-by-lee-babin/</link>
		<comments>http://www.devchix.com/2006/12/13/book-review-beginning-ajax-with-php-by-lee-babin/#comments</comments>
		<pubDate>Wed, 13 Dec 2006 14:26:54 +0000</pubDate>
		<dc:creator>Nola</dc:creator>
		
		<category><![CDATA[Book]]></category>

		<category><![CDATA[Javascript/AJAX]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://www.devchix.com/?p=18</guid>
		<description><![CDATA[Book Review
Beginning Ajax with PHP by Lee Babin, published by Apress
Book Site &#124; Sample Chapter: 3 PHP and Ajax &#124; Table of Contents
Although no stranger to Ajax, I received a review copy of Beginning Ajax with PHP expecting some watered down presentation of Javascript with some PHP thrown in. I was quite surprised to find [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Book Review<br />
Beginning Ajax with PHP by Lee Babin, published by Apress</p>
<p class="MsoNormal"><a href="http://apress.com/book/bookDisplay.html?bID=10117">Book Site</a> | <a href="http://apress.com/book/supplementDownload.html?bID=10117&#038;sID=3896">Sample Chapter: 3 </a><a href="http://apress.com/book/supplementDownload.html?bID=10117&#038;sID=3896">PHP and Ajax</a> | <a href="http://apress.com/book/supplementDownload.html?bID=10117&#038;sID=3897">Table of Contents</a></p>
<p class="MsoNormal">Although no stranger to Ajax, I received a review copy of <em>Beginning Ajax with PHP</em> expecting some watered down presentation of Javascript with some PHP thrown in. I was quite surprised to find a good presentation of using Ajax and PHP, easy enough for the beginner and still interesting for those who have done it for years.</p>
<p class="MsoNormal">
<p class="MsoNormal">The book starts out exactly how I would write it &#8212; SIMPLE! The first time I did Ajax with XHR (xml http request), I used a plain text file, which I then read into a DIV at the click of a link. This takes a similar approach and has data stored in an array which is then accessed with a simple call to a PHP file. The following chapter, takes it a step further and this building upon previous chapters is a common theme in the book.</p>
<p class="MsoNormal">
<p class="MsoNormal">After going through the basics, the book gets into more practical uses of Ajax. The latter chapters talk about using forms to pass along data to be processed by Ajax and doing form validation. It also gives a good explanation of the proper use of the form methods GET and POST. It goes into detail about uploading images and other files using a hidden form submit trick, since XHR doesn&#8217;t support file uploading (javascript is not allowed to access files on your harddrive). And this chapter is the perfect predecessor to the &#8220;Real-World Ajax Application&#8221; chapter where you will take what you have learned and create an Ajax based photo gallery. Practical, hand-on is the best way to learn something IMHO (Sorry &#8220;Hello World&#8221; scripts!). It is interesting that this chapter is in the middle of the book, when I would expect it at the end. Perhaps the author wanted the user to jump in and try it, instead of persevering to the end. I don&#8217;t know about you, but often the last few chapters of the book go unread by me.</p>
<p class="MsoNormal">
<p class="MsoNormal">After the reader has confidence on how to use AJAX, the book gives the warning, Ã¢â‚¬Å“Whoa! Wait a minute! AJAX isn&#8217;t appropriate for EVERYTHING!Ã¢â‚¬Â It gives examples of when AJAX would be a good idea and when it would not. I think this is pretty important as each CEO now wants Ajax everywhere in their application but it&#8217;s not always the best solution! And it talks about the classic, Ã¢â‚¬Å“THE BACK BUTTONÃ¢â‚¬Â, problem. Then, in the same chapter, the book takes sort of a funny turn (in my opinion) and gives an introduction to PEAR.  The book explains how to use PEAR&#8217;s HTML_TABLE class to illustrate a good use for Ajax in creating an Excel-like grid that sums columns. This is a very cool class but would have been better suited for an appendix.</p>
<p class="MsoNormal">
<p class="MsoNormal">The rest of the book seems to be a random splattering of interesting topics: web services, map applications, cross-browser issues (touches again on the back button problem - but a solution this time!). There is also a brief mention of security. This should have been more in the middle of the book (see above for skipped last chapters syndrome). What then follows is a testing and debugging chapter which would have been more effective as the 3 or 4th chapter in the book. Finally there is a chapter about the browser DOM.</p>
<p class="MsoNormal">
<p class="MsoNormal">A great minor addition to the book would be an overview of some Ajax libraries such as Prototype, JQuery, Dojo, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.devchix.com/2006/12/13/book-review-beginning-ajax-with-php-by-lee-babin/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
