Hi there. I have very specific problem with Prototype. I'm getting selection of document and make a range from it. It's simple. But I'm receiving not extended elements from <range.startContainer>. Ok. That's fine. I would like to add prototype's functions to this element. var container = range.startContainer; container = Element.extend(container); // NOT WORKS! // container still not have Prototype function, like childElements ;-( How to extend DOM element with Prototype properly? P.S. In any case, I can live without this feature, but, as for me, it's better to use Prototype anywhere ;-) but not browser specific features ;-)
on 2008-07-01 15:51
on 2008-07-01 16:04
What is range.startContainer? Are you sure it's an element? -Fred On Tue, Jul 1, 2008 at 8:50 AM, AlannY <m@alanny.ru> wrote: > > Hi there. I have very specific problem with Prototype. > > I'm getting selection of document and make a range from it. It's > simple. But I'm receiving not extended elements from > <range.startContainer>. Ok. That's fine. I would like to add > prototype's functions to this element. -- Science answers questions; philosophy questions answers.
on 2008-07-01 17:39
Yes, it's an element var container = range.startContainer; alert(container.tagName); // OK This elements from iframe, where Prototype is not loaded, so, I want to extend element manually ;-)
on 2008-07-01 21:54
This should work in browsers which expose "prototype" of host objects
(e.g. any recent gecko, webkit, etc.):
var r = document.createRange();
var proto = r.startContainer.constructor.prototype;
for (var prop in Element.Methods) {
if (!Object.isFunction(Element.Methods[prop])) continue;
proto[prop] = Element.Methods[prop].methodize();
}
-- kangax