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 2008-06-28 01:42
on 2008-06-28 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 2008-06-28 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 2008-06-29 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 2008-07-10 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 2008-07-10 16:58
There were some changes to #getDimensions in recent commits. Could you check if trunk version works properly? -- kangax
on 2008-07-10 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 2008-07-10 17:40
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...
on 2008-07-10 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 2008-07-11 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 2008-07-11 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 2008-07-11 16:44
here's my screenshots about my div element that has all the prototype methods as attributes : http://rubyonrails-spinoffs.googlegroups.com/web/i...
on 2008-07-11 23:55
If $$('#foo')[0] !== $('foo') then it is definitely a bug. Could you
please file it?
-- kangax