Object.extend(Element.Methods, ... IE problem

8 views
Skip to first unread message

mocambo

unread,
Jun 27, 2008, 7:41:25 PM6/27/08
to Ruby on Rails: Spinoffs
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 ?

kangax

unread,
Jun 27, 2008, 9:09:06 PM6/27/08
to Ruby on Rails: Spinoffs
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

mocambo

unread,
Jun 28, 2008, 4:21:44 PM6/28/08
to Ruby on Rails: Spinoffs
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? :)

kangax

unread,
Jun 28, 2008, 11:06:47 PM6/28/08
to Ruby on Rails: Spinoffs
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

Gareth Evans

unread,
Jul 1, 2008, 8:52:39 PM7/1/08
to rubyonrail...@googlegroups.com
And what is the body of ownMethod?

rachid

unread,
Jul 10, 2008, 10:46:13 AM7/10/08
to Ruby on Rails: Spinoffs
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 :( :( :(

kangax

unread,
Jul 10, 2008, 10:57:01 AM7/10/08
to Ruby on Rails: Spinoffs
There were some changes to #getDimensions in recent commits. Could you
check if trunk version works properly?

-- kangax

rachid

unread,
Jul 10, 2008, 11:19:21 AM7/10/08
to Ruby on Rails: Spinoffs
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 ???

rachid

unread,
Jul 10, 2008, 11:39:54 AM7/10/08
to Ruby on Rails: Spinoffs

jdalton

unread,
Jul 10, 2008, 1:09:16 PM7/10/08
to Ruby on Rails: Spinoffs
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?

rachid

unread,
Jul 11, 2008, 4:20:02 AM7/11/08
to Ruby on Rails: Spinoffs
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

rachid

unread,
Jul 11, 2008, 10:40:16 AM7/11/08
to Ruby on Rails: Spinoffs
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

rachid

unread,
Jul 11, 2008, 10:44:34 AM7/11/08
to Ruby on Rails: Spinoffs

kangax

unread,
Jul 11, 2008, 5:54:19 PM7/11/08
to Ruby on Rails: Spinoffs
If $$('#foo')[0] !== $('foo') then it is definitely a bug. Could you
please file it?

-- kangax

On Jul 11, 10:44 am, rachid <r.bahass...@gmail.com> wrote:
> here's my screenshots about my div element that has all the prototype
> methods as attributes :http://rubyonrails-spinoffs.googlegroups.com/web/ie%20developer%20too...

rachid

unread,
Jul 15, 2008, 3:45:07 AM7/15/08
to Ruby on Rails: Spinoffs
$$('#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.
Reply all
Reply to author
Forward
0 new messages