Hi.

Imagine a component which has a method which allows a third party to
supply some data after the initial creation of the component using
"new".

e.g.

// Initial creation.
var myComp = new MagicComp({option1:value1, option2:value2});

// Some time later, maybe as a result of a click event.
myComp.setItems({item1:value1, item2:value2});

sort of thing.



Now, a common pattern would be to use an Ajax.Request to get the data.


I would like to have the ability to pass the ajax request as part of
the initial creation, but to not have the request actually actioned
until some time later.

Does the creation of an Ajax.Request force the execution of the
request in all circumstances.

I suppose all I'm really interested in is the URL of the request, but
I'd like to allow third parties more control over this if necessary.

// Initial creation.
var myCompAjaxed = new MagicCompAjaxed({option1:value1, ajax:new
AjaxRequestButNotYetActive()})


Ultimately, I'm trying to delay the request and processing within the
component until it is actually needed. And so I want to be able to
define all the information (params, callbacks, etc.) for the
Ajax.Request, but just not have it run until needed (just-in-time).

It would look like that my best option is something like ...

// Initial creation.
var myCompAjaxed = new MagicCompAjaxed({
 option1:value1,
 AjaxRequestURL : '....';
 AjaxRequestOptions : {...}
});

and have ...

MagicCompAjaxed.doTheWork : function(){ new
Ajax.Request(this.AjaxRequestURL, this.AjaxRequestOptions)}

sort of thing.

But then how do I extract the data from the request (onSuccess()) but
still allow the end user to have an onSuccess option?

Argh.

Inheritence is the answer here ... just getting a little lost...

Or going down the wrong track entirely!




Any ideas/suggestions/examples/etc.

Regards,

Richard Quadling.

-- 
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 prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to