Forum: Rails Spinoffs (closed, excessive spam) Object.extend(Element.Methods, ... IE problem

57564570dcbfeb09e90c3fb913a7daf4?d=identicon&s=25 mocambo (Guest)
on 2008-06-28 01:42
(Received via mailing list)
I've tried to extend Element.Methods with my own new method. All works
perfectly under FF and Safari but IE6 says "Object doesn't support
this property or method" when I call this new method.

Object.extend(Element.Methods, {
  ownMethod: function(element) {
  }
});

Element.addMethods();

$('someDiv').ownMethod();

Is there any common solution ?
F1fcf834ddad415f60d29c87cc10d4d4?d=identicon&s=25 kangax (Guest)
on 2008-06-28 03:09
(Received via mailing list)
This should work (at least in recent versions of prototype).
Have you tried passing an object with methods explicitly?

Element.addMethods({
  ownMethod: function(element) {
    // ...
  }
})

-- kangax
57564570dcbfeb09e90c3fb913a7daf4?d=identicon&s=25 mocambo (Guest)
on 2008-06-28 22:22
(Received via mailing list)
My testing results on both way:

1. ------------------------------------
Object.extend(Element.Methods, {
        ownMethod: function(element) {
            // ...
        }

});

Element.addMethods();

and

2. ------------------------------------
Element.addMethods({
  ownMethod: function(element) {
      // ...
  }
});

Element.ownMethod($('someDiv')); works on FF, Safari and IE as
expected on both way.

$('someDiv').ownMethod(); works still only on FF and Safari. Not on IE
"Object doesn't support
this property or method".

I think there's no more tricks to get $('someDiv').ownMethod();
working on IE? :)
F1fcf834ddad415f60d29c87cc10d4d4?d=identicon&s=25 kangax (Guest)
on 2008-06-29 05:07
(Received via mailing list)
There should be no "tricks" to get this working : )
Passing element to $ should extended it with all Element.Methods.*
defined for that element type.
I really have no clue why this would fail.
Exactly which element (i.e. its tagName) are you calling method on?

-- kangax
6e780ee0dc0dd59c93cdcaf45cdef2e4?d=identicon&s=25 Gareth Evans (Guest)
on 2008-07-02 02:53
(Received via mailing list)
And what is the body of ownMethod?
527dcf57aa93a08df30948a15b5f5026?d=identicon&s=25 rachid (Guest)
on 2008-07-10 16:47
(Received via mailing list)
I have the same pb with getDimensions() :
Example :

$('elt').getDimensions()

It works in FF but in IE : "Object doesn't support this property or
method";

Finally i used native clientWidth and clientHeight :( :( :(
F1fcf834ddad415f60d29c87cc10d4d4?d=identicon&s=25 kangax (Guest)
on 2008-07-10 16:58
(Received via mailing list)
There were some changes to #getDimensions in recent commits. Could you
check if trunk version works properly?

-- kangax
527dcf57aa93a08df30948a15b5f5026?d=identicon&s=25 rachid (Guest)
on 2008-07-10 17:19
(Received via mailing list)
The pb does not come from getDimensions.
I 've tried to alert all of my element methods in IE doing this :

alert($H( $('elt') ).inspect())

Result :
==> In FF the alert show me all prototypejs Element.methods
==> In IE the alert show me only native javascript attributes and
methods

Element seems have no prototypejs methods. Maybe the
Element.addMethods bugs ???
527dcf57aa93a08df30948a15b5f5026?d=identicon&s=25 rachid (Guest)
on 2008-07-10 17:40
(Received via mailing list)
i ve added the screenshots of alerts ( alert($H( $
('elt') ).inspect())  )

ON IE :
http://groups.google.com/group/rubyonrails-spinoff...

ON FF

http://groups.google.com/group/rubyonrails-spinoff...
299a3d891ff1920b69c364d061007043?d=identicon&s=25 jdalton (Guest)
on 2008-07-10 19:11
(Received via mailing list)
What version of IE are you using.
Prototype supports IE 6+

Is your Element ID unique?
Is it an html element and not an xml node?
Is it an ID and not a name attribute?
Are you calling this after the dom has loaded?
527dcf57aa93a08df30948a15b5f5026?d=identicon&s=25 rachid (Guest)
on 2008-07-11 10:20
(Received via mailing list)
1 - I tried it on IE 6 and IE 7, same alert on both and same error.

2 - My ID is unique, i only have a same element class like this:
<div id="search">
  <div class="search">
  </div>
</div>
        ==> But i already tried to rename the id "search" by "foo" or
"bar" >> same error

3 - Like you can see it's a <div> node and not XML

4 - It is an ID and not a name... lol

5 - I tried to call it in 2 way :
        a - Event.observe(window, 'load', go_search, false);

        b - <a onclick="go_search()" href="#">search</a>

   Then DOM is loaded

6 - Finally i use prototype 1.6.0.2

Nothing to do....

I m still searching....

THX
527dcf57aa93a08df30948a15b5f5026?d=identicon&s=25 rachid (Guest)
on 2008-07-11 16:40
(Received via mailing list)
I answer myself for those who will have this pb, there are two
solutions when this error occurs in ie 6 or ie 7 :
1 - you say fuck prototype and you usie native javascript methods :
          ==> elt.setStyle({foo:bar})  <<>>  elt.style.foo="bar"
          ==> elt.getDimensions().height  <<>> elt.clientHeight
(warning with this there are differences between FF and IE)

2 - you absolutely want to use prototype, so you put your element in a
$$ method and magic happens!
  In My example :
        ==> $('search').getDimensions().height return an error "Object
doesn't support this property or method"
And with the magic method IE is happy :
        ==> $$('#search')[0].getDimensions().height;

GREAT!

....
By searching more , i found it's not so magic. $$ add methods to
elements... For those who have IE DEVELOPER TOOLBAR, you can make a
test by inspecting an HTML ELEMENT that was called by $$, very
nice :D :D :D :D
527dcf57aa93a08df30948a15b5f5026?d=identicon&s=25 rachid (Guest)
on 2008-07-11 16:44
(Received via mailing list)
here's my screenshots about my div element that has all the prototype
methods as attributes :
http://rubyonrails-spinoffs.googlegroups.com/web/i...
F1fcf834ddad415f60d29c87cc10d4d4?d=identicon&s=25 kangax (Guest)
on 2008-07-11 23:55
(Received via mailing list)
If $$('#foo')[0] !== $('foo') then it is definitely a bug. Could you
please file it?

-- kangax
527dcf57aa93a08df30948a15b5f5026?d=identicon&s=25 rachid (Guest)
on 2008-07-15 09:45
(Received via mailing list)
$$('#foo')[0] is not always $('foo'). We developped a project with
more than 200 pages. And this bug appear only in 2 pages (with the
same javascript). I'll file it when i'll find its origin.
This topic is locked and can not be replied to.