Hi,

> I'm writing an app which retrieves an RSS feed and processes it.  I'd
> like to use the Prototype methods on it, but first it must be
> extended.

I'm guessing if you're dealing with RSS, you're talking about
processing XML.  Someone jump on me if I'm wrong, but I don't think
Prototype currently supports doing DOM extensions on XML elements.
Prototype currently extends instances of the host objects directly
rather than wrapping them, and this runs into all sorts of trouble
with certain browsers from a major software firm in Washington.  So at
the moment, AFAIK, Prototype's DOM stuff is HTML only.  A future
version of Prototype currently being developed will use wrapper
objects rather than directly modifying the host objects, and so will
be able to support XML.

So I think that's your answer, for the moment.  But a couple of notes
on the code you posted:

>                 window.console.log("document.select: " + document.select);  //
> returns undefined

'document' in that code is the (HTML) document you're in, not anything
to do with the Ajax call.  Note that 'document' is not an Element (as
per the DOM[1]), and so it doesn't have the Element methods.
'document' is a Document and a Node, but not an Element.  Similarly,
your later line trying to extend responseXML would be trying to extend
a Document rather than an element (you'd want to find the root Element
within the Document instead), but again -- right now that doesn't work
anyway, so...

> The documentation says:
>
> extend
>
> extend(element)
>
> Extends element with all of the methods contained in Element.Methods
> and Element.Methods.Simulated....

True, although 99.9% of the time people use $[2] instead.  It's not
just for looking things up by ID, it also extends an element if given
an unextended one.

[1] http://www.w3.org/DOM/
[2] http://prototypejs.org/api/utility/dollar

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Mar 15, 6:39 am, Doug Reeder <[email protected]> wrote:
> I'm writing an app which retrieves an RSS feed and processes it.  I'd  
> like to use the Prototype methods on it, but first it must be  
> extended.  The documentation says:
>
> extend
>
> extend(element)
>
> Extends element with all of the methods contained in Element.Methods  
> and Element.Methods.Simulated....
>
> which is not much help in extending an element _not_ in the global  
> document tree.    The pagehttp://prototypejs.org/learn/extensions
> gives the example:
>
> var my_div = document.createElement('div');
>
> Element.extend(my_div);
> my_div.addClassName('pending').hide();
>
> so I wrote the following code to try and test this:
>
> function doProcess(response) {   // this is the onSuccess method of an  
> Ajax.Request
>         try {
>                 window.console.log("document.select: " + document.select);  
> //  
> returns undefined
>                 var docext = Element.extend(document);
>                 window.console.log("docext.select: " + docext.select);  // 
> returns  
> undefined
>
>                 var ext = Element.extend(response.responseXML);
>                 window.console.log(ext);
>                 window.console.log("ext.select: " + ext.select);  // returns 
> undefined
>                 window.console.log(ext.select("item"));  // throws a TypeError
>                 window.console.log("num items " + items.length);
>                 for (i=0; i<items.length; ++i) {
>                         window.console.log(items[i].nodeName);
>                 }
>         } catch (error) {
>                 window.console.log(error);
>         }
>
> }
>
> so, how do I actually extend documents and elements that are not part  
> of the global documents tree?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to