[OpenLayers-Users] How to preset a parameter into a callback function?

Pedro Baracho pedropbaracho at gmail.com
Mon Nov 30 13:16:27 EST 2009


OpenLayers.Function.bind is exactly what I am looking for. At least if it is
the same as the Prototype one.
Sorry for disturbing you guys before trying it out.

On Mon, Nov 30, 2009 at 3:53 PM, Pedro Baracho <pedropbaracho at gmail.com>wrote:

> In some part of my code I am sending multiple requests asynchronously to
> some servers. The problem is: I need some information from the requests
> (like server address and URL string) in order to process the responses and
> these informations aren't available in the response parameter (which is
> something like a GML). That being said, I think the best way is to preset
> some parameters in the callback function when sending the requests.
>
> I found this solution:
> http://openlayers.org/pipermail/users/2009-March/010890.html which
> partially explains OpenLayers.Function.bind() and gives another option of
> using the scope to set the parameter.
>
> The problem with these solutions is that I need the scope to be on the
> current object AND set additional parameters. In other words, I CAN'T change
> the scope, which means either I set these parameters inside the scope in
> some sort of twisted temporary variables or I use some unknown method which
> allows me to tell OpenLayers: "When calling the callback function, set these
> parameters additionally to the response".
>
> This is what I have:
>
> for (i in servers) {
>     OpenLayers.Request.issue({
>         url: servers[i],
>         headers: {...},
>         params: {...}
>         success: this.someFunction,
>         scope: this
>     });
> }
>
> This is what I need:
>
> for (i in servers) {
>     OpenLayers.Request.issue({
>         url: servers[i],
>         headers: {...},
>         params: {...}
>         success: this.someFunction(i, response), // preset parameter "i"
>         scope: this
>     });
> }
>
> Is OpenLayers.Function.bind() what I am looking for? If it is, how do I use
> it? I didn't find any docs on it, on OL API.
>
> Thanks in advance.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091130/e2836e94/attachment.html


More information about the Users mailing list