Omg lol this is my point...

All you have itterated is what i have worked out for myself already and 
replied subsequently to that effect (friday i think).

Regards

Alex Mcauley
http://www.thevacancymarket.com
----- Original Message ----- 
From: "T.J. Crowder" <t...@crowdersoftware.com>
To: "Prototype & script.aculo.us" <prototype-scriptaculous@googlegroups.com>
Sent: Wednesday, August 26, 2009 10:40 AM
Subject: [Proto-Scripty] Re: Ajax requests again



Alex,

> 1. Element that triggered the call (if any)

"if any" doesn't make any difference to the question -- again, you
can't get that information from Ajax.Request or Ajax.Updater, because
it's not passed into them (whether it exists or not). You can only get
that information if you pass it into something of your own.

Sorry if I'm completely missing what you're talking about, but I think
a wrapper solution is your best bet.
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available


On Aug 26, 9:53 am, "Alex McAuley" <webmas...@thecarmarketplace.com>
wrote:
> My mistake...
>
> i meant.
>
> 1. Element that triggered the call (if any)
> 2. Element receiving the response (if any)
>
> Alex Mcauleyhttp://www.thevacancymarket.com
>
>
>
> ----- Original Message -----
> From: "T.J. Crowder" <t...@crowdersoftware.com>
> To: "Prototype & script.aculo.us" 
> <prototype-scriptaculous@googlegroups.com>
> Sent: Wednesday, August 26, 2009 9:47 AM
> Subject: [Proto-Scripty] Re: Ajax requests again
>
> Alex,
>
> > 1. The element that triggered the call
>
> What element? Ajax calls can be initiated by any code, anywhere, and
> don't necessarily have anything to do with any element "triggering"
> them. For example:
>
> function pollForData() {
> new Ajax.Request(pollurl, {
> onSuccess: function(resp) {
> doSomethingWithTheData(resp);
> },
> onComplete: function() {
> window.setTimeout(pollForData, pollForDataInterval);
> }
> });
> }
> document.observe("dom:loaded", function() {
> window.setTimeout(pollForData, pollForDataInterval);
> });
>
> There's no element associated with the call. Even in cases where there
> is (a request triggered by a button click, for instance), we don't
> pass that element into Ajax.Request in any defined way, so there's no
> defined way for you to get it.
>
> I think your requirement is at a level above Ajax.Request and
> Ajax.Updater, and that you should put your own infrastructure in place
> for it. For example:
>
> var MoreAjax = {
> react: function(element, url, options) {
> var completeCallback;
>
> element = $(element);
> element.disable();
> if (!options) options = {};
> completeCallback = options.onComplete;
> options.onComplete = function() {
> element.enable();
> if (completeCallback) {
> completeCallback.apply(undefined, arguments);
> }
> };
> }
> };
>
> That defines an explicit way for you to say "this call was triggered
> by this element" and it provides automatic element disabling/
> enabling. So in a click handler:
>
> $('mybutton').observe('click', function(event) {
> event.stop();
> MoreAjax.react(this, 'myurl', {
> parameters: this.up('form').serialize({hash: true}),
> onSuccess: function(resp) {
> // Some nifty thing
> }
> });
> });
>
> Voila, the button is disabled during the request and enabled when it's
> done.
>
> I'm sure that function as written (er, dashed off) is completely wrong
> for what you're trying to do, it just illustrates the idea.
>
> In my apps, I never use Ajax.Request or Ajax.Updater directly. I
> always have wrappers that factor out the complexity in ways
> appropriate to the application.
>
> FWIW!
> --
> T.J. Crowder
> tj / crowder software / com
> Independent Software Engineer, consulting services available
>
> On Aug 26, 9:25 am, "Alex McAuley" <webmas...@thecarmarketplace.com>
> wrote:
> > Really?
>
> > I thought the explination was a simple one.
>
> > To recap....
>
> > A global way of knowing what is going on inside Ajax requests including.
>
> > 1. The element that triggered the call
> > 2. The container (if Ajax.Updater) the response is going to.
>
> > Yes i have looked at Responders and i am using them now to lock 
> > (disable)
> > input elements but as i cannot get the element that triggered the call i
> > have to lock the whole document which is not neccesary and slow - it 
> > would
> > be better to find the parent or inputs above the callee and lock them
> > while
> > the request is going on (to stop people pushing the button twice etc 
> > etc)
> > then unlock on onComplete.
>
> > My way is working fine at the moment ... but ... it would be quicker and
> > more efficient if i could in some way get the nodes/elements i desire on 
> > a
> > global basis as part fo the framework and not hacked ontop of it.
>
> > Hope this clears things up a bit
>
> > Alex Mcauleyhttp://www.thevacancymarket.com
>
> > ----- Original Message -----
> > From: "Timo" <timo.kiss...@gmail.com>
> > To: "Prototype & script.aculo.us"
> > <prototype-scriptaculous@googlegroups.com>
> > Sent: Tuesday, August 25, 2009 4:11 PM
> > Subject: [Proto-Scripty] Re: Ajax requests again
>
> > > On 20 Aug., 17:15, Alex Mcauley <webmas...@thecarmarketplace.com>
> > > wrote:
> > >> earlier on in the month i posted on how to do some things with Ajax
> > >> requests genericaly like adding a loading message to all requests and
> > >> i got a couple of responses but not many.
>
> > >> I've been giving it alot of thought and i cam up with addMethods as a
> > >> way to add some things to the Ajax Class...
>
> > >> Could anyone give me an example of how to do this with addMethods -
> > >> just a hello world will do then i can take it from there
>
> > > I am not sure I understand what you are trying to achieve (and I
> > > couldn't find the older topic you mention),
> > > but did you look at Ajax.Responders? [http://www.prototypejs.org/api/
> > > ajax/responders]
>
> > > Timo



--~--~---------~--~----~------------~-------~--~----~
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-scriptaculous@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