The docs say that spinnerTarget is part of the default options passed to the
Request instance:

* requestOptions - (*object*) The options passed on to the instance of
[Request.HTML] created by the class that sends the form. Defaults to
*{evalScripts: true, useSpinner: true, url: <the form url>, emulation:
false, spinnerTarget: <the update argument>}*.

What this means is your code should look like this:

               new Form.Request(
                       id,
                       container,
                       {requestOptions: { spinnerTarget: container } }
               );

Spinner integrates with Request; so it's the Request's options you need to
specify here. You'll note in the relevant code that it calls $merge on the
fault options and this.options.requestOptions.


On Fri, Feb 12, 2010 at 12:06 PM, hairbo <[email protected]> wrote:

> Hi,
>
> I'm using Form.Request, and just discovered that it can do that nifty
> spinner thing.  It wasn't working for me initially because I didn't
> have the proper spinner styles or the graphic.  So I grabbed those,
> and it's basically working, but now I'm having a problem with
> spinnerTarget.
>
> According to the docs, I should be able to pass in an element or id of
> an element to "spinnerTarget", and during the submit, that given
> element should be where the spinner is applied.  In practice, that
> doesn't seem to be the case.  My call looks like this:
>
> sessionsubmit: function (id, container) {
>        if($(id)) {
>                var gsubmit = new Form.Request(
>                        id,
>                        container,
>                        {spinnerTarget: container}
>                )
>        }
> }
>
> If I do console.log() on "container" or even $(container), the code
> finds it, so I know it's there.  However, it would appear that the
> underlying Mootools code is hardwired to have the spinner appear on
> the form (in my case 'id').  Here's what I think is the relevant code:
>
>                makeRequest: function(){
>                        this.request = new Request.HTML($merge({
>                                        url: this.element.get('action'),
>                                        update: this.update,
>                                        emulation: false,
>                                        spinnerTarget: this.element,
>                                        method: this.element.get('method')
> || 'post'
>                        }, this.options.requestOptions)).addEvents({
>                                success: function(text, xml){
>                                        ['success',
> 'complete'].each(function(evt){
>                                                this.fireEvent(evt,
> [this.update, text, xml]);
>                                        }, this);
>                                }.bind(this),
>                                failure: function(xhr){
>                                        this.fireEvent('failure', xhr);
>                                }.bind(this),
>                                exception: function(){
>                                        this.fireEvent('failure', xhr);
>                                }.bind(this)
>                        });
>                },
>
> It would appear that "spinnerTarget" is hardwired to the ID of the
> form being submitted.  Maybe I'm missing something...
>
> Thanks for any guidance.
>
>

Reply via email to