( ꒪⌓꒪) ゆるよろ日記

( ゚∀゚)o彡°オパーイ!オパーイ! ( ;゚皿゚)ノシΣ フィンギィィーーッ!!!

ActiveScaffoldをFirefox3で動かすためのパッチ

さっそく入れましたよ、Firefox3。
で、ActivescaffoldでRJSエラーがでますよゴルァ。

RJS error:
 
TypeError: $$("#member-create--form a.cancel").first().link is undefined

調べたら、パッチが出てるみたいなんで当てたらなおったよ。
http://groups.google.com/group/activescaffold/browse_thread/thread/2ebd97cba2569f44
http://code.google.com/p/activescaffold/issues/detail?colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary&q=548&can=2&id=548

/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js
267行目をコメントアウトして、register_cancel_hooksを以下のようにするとOK。

  register_cancel_hooks: function() {
    // anything in the insert with a class of cancel gets the closer method, and a reference to this object for good measure
    var self = this;
    // this.adapter.getElementsByClassName('cancel').each(function(elem) {
    this.adapter.select('.cancel').each(function(elem) {
      elem.observe('click', this.close_handler.bind(this));
      elem.link = self;
    }.bind(this))
  },

The problem that is in Firefox 3 there is a native version of
getElementsByClass that returns a NodeList instead an Array like the
prototype version does.

Firefox3では、ネイティブで実装されるgetElementsByClass(classname)が
prototype.jsのようにArrayの代わりにNodeListを返すようになったのが原因のようです。