Archive for February, 2008

Using ExtJS tree on rails with the prototype adapter

February 22, 2008

UPDATE: Notice that the new version of ExtJS is now on Prototype 1.6, yeah…

So I’m doing a folder tree using the ExtJS javascript with the prototype library adapter. I’m pretty much doing this.

This was somewhat working. Every third or forth browser refresh the tree didn’t load any nodes. Very odd indeed. I debugged my way through using Firebug, but when this was on, it worked everytime. Since Firebug slows down the entire javascript environment I concluded that the error occured when something (or loading) happened too fast.

In the ext-all-debug.js (version 2.0.1) I tracked the error down to line 23754. The json result being evaluated is undefined (notice that this only happens some of the time). So… after hours of head scratching and putting alerts in both the prototype library and ExtJS library to see what was wrong, it hit me…

The version ExtJS I have, come bundled with prototype 1.5.0 while rails 2.0.2 comes with prototype 1.6.0.1. In my layout I simply included <%= javascript_include_tag :defaults %>, but after I changed this to:

<%= javascript_include_tag “application.js” %>
<%= javascript_include_tag “ext/adapter/prototype/prototype.js” %>
<%= javascript_include_tag “ext/adapter/prototype/effects.js” %>

Everything seemed to work. Now my only problem is that I now use Rails 2.0.2 with an old version of prototype. So can I use all the rails helpers?!?


Design a site like this with WordPress.com
Get started