Monthly Archive for April, 2011

Dynamic AJAX Content, Internet Explorer, MooTools, and Form Elements

Another day, another Internet Explorer bug. I was using MooTool’s Request.HTML to load some AJAX content to display within an inline popup and IE kept throwing the classic “Object doesn’t support this property or method” error. The error was occurring inside document.id (i.e. the dollar function) which made the issue even stranger. Looking at the dollar function’s source code, it seems as though methods are copied from Element.prototype to the element being retrieved.

The AJAX content I was loading contained a form which had a form element with ID “position”. When the Request.HTML receives html content it retrieves a list of all elements contained with the AJAX response using getElements(“*”). This caused the document.id method to be called with the form element of ID “position” contained within the HTML response as its argument, which caused the following assignment to be made:

theFormElement["position"] = Element.prototype["position"];

Which then triggered the above mentioned IE error. Since theFormElement["position"] is a read-only reference to the input element contained within the form IE threw an error. Be aware of the ID / name you assign to input elements when debugging obscure bugs in internet explorer!

Using VMWare + Windows to Test Web Sites on Windows

Step 1: Retrieve Emulator’s Gateway IP Address

Grab the inet number resulting fromĀ 

`ifconfig vmnet1`.

Step 2: Add Test Site’s Local Hostname to Window’s Host File

For each site I develop I setup a new Apache virtual host (some info on apache virtual hosts here). For instance, the local domain / hostname for a website could be

mabblog.localhost

. When developing locally there are some hardlinks to the local development hostname, for this reason the it isn’t enough to use the inet vmnet1 address retrieved above when debugging in VMWare / Parallels; the local hostname must be added to the Windows host file.

Wikipedia has an extensive listing of the location of the host file on various systems, on Windows XP it is located here:

c:\windows\system32\drivers\etc\hosts

Open up the file in notepad and add your host entry, for example:

172.16.232.1    abc.localhost

Step 3: Add Emulator’s Gateway IP Address to Your VirtualHost

In order for apache to properly handle the request coming from the emulator gateway you have to add the emulator gateway IP to the VirtualHost statement.

From: /etc/apache2/users/Name.conf

NameVirtualHost 172.16.232.1
<virtualhost 127.0.0.1 172.16.232.1>
ServerName abc.localhost
DocumentRoot /Users/Mike/Sites/abc
</virtualhost>

References: