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 ?
on 28.06.2008 01:42
on 28.06.2008 03:09
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
on 28.06.2008 22:22
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? :)
on 29.06.2008 05:07
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
on 02.07.2008 02:53
And what is the body of ownMethod?
on 10.07.2008 16:47
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 :( :( :(
on 10.07.2008 16:58
There were some changes to #getDimensions in recent commits. Could you check if trunk version works properly? -- kangax
on 10.07.2008 17:19
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 ???
on 10.07.2008 17:40
i ve added the screenshots of alerts ( alert($H( $
('elt') ).inspect()) )
ON IE :
http://groups.google.com/group/rubyonrails-spinoffs/web/ie%20alert%20elements%20methods.jpg
ON FF
http://groups.google.com/group/rubyonrails-spinoffs/web/ff%20alert%20elements%20methods.jpg
on 10.07.2008 19:11
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?
on 11.07.2008 10:20
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
on 11.07.2008 16:40
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
on 11.07.2008 16:44
here's my screenshots about my div element that has all the prototype methods as attributes : http://rubyonrails-spinoffs.googlegroups.com/web/ie%20developer%20toolbar%20div%20prototype%20method.jpg?gsc=M1GLeRYAAAB1z1bqtwE3VkDwdpHqENu5vmqfzrIRh74LnVxB_8J-NQ
on 11.07.2008 23:55
If $$('#foo')[0] !== $('foo') then it is definitely a bug. Could you
please file it?
-- kangax
on 15.07.2008 09:45
$$('#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.