You are using chain correctly.
However, this doesn't make much sense to me:
this.chain(f1, f2);
this.callChain();
is the same as:
f1();
this.chain(f2);
or
this.chain(f2);
f1();
There's no point in adding a function to the chain stack if you're going to
immediately call it...
On Tue, Oct 14, 2008 at 11:54 PM, Marco M. Jaeger <
[EMAIL PROTECTED]<[EMAIL PROTECTED]>
> wrote:
>
> Hello
> Hope somebody can help real quick to confirm that this is the way to
> do it:
>
> I've an AJAX request that is supposed to update some fields
> onComplete.
>
> this is the code I have:
>
> getdata:function() {
> // fetch geodata and update form fields
> this.chain (
> function() {
> this.fetchGeodata(new GLatLng(lat,
> lng));
> }.bind(this),
> function() {
> var geodata = this.geodata;
> $('txtAlt').set('value',
> geodata.alt);
> $('txtTitle').set('value',
> geodata.name);
> }
> );
> this.callChain();
> }
>
>
> the onComplete method of the ajax request issues this.callChain then
> for the 2nd time.
>
> fetchGeodata: function(latlng) {
> if (!latlng) return false;
> var request = new Request({
> url: './scripts/requestGeodata.php',
> autoCancel: true,
> onSuccess: function(responseText,
> responseXML) {
>
> this.geodata =
> JSON.decode(responseText);
> this.callChain();
>
> }.bind(this)
> }).send({ lat: latlng.y, lng: latlng.x, mod: 'json'
> });
> },
>
>
>
> It seems to work but I don't know if this is the way to do it.
>
>
> ------------------------------
> View message @
> http://n2.nabble.com/Chain%3A-some-confusion-tp1335864p1335864.html
> To start a new topic under MooTools Users, email
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> To unsubscribe from MooTools Users, click here< (link removed) >.
>
>
>
-----
The MooTools Tutorial: http://www.mootorial.com www.mootorial.com
CNET Clientside: http://clientside.cnet.com clientside.cnet.com
--
View this message in context:
http://n2.nabble.com/Chain%3A-some-confusion-tp1335864p1337638.html
Sent from the MooTools Users mailing list archive at Nabble.com.