OpenLayers.Function.bind is exactly what I am looking for. At least if it is the same as the Prototype one.<br>Sorry for disturbing you guys before trying it out.<br><br><div class="gmail_quote">On Mon, Nov 30, 2009 at 3:53 PM, Pedro Baracho <span dir="ltr"><<a href="mailto:pedropbaracho@gmail.com">pedropbaracho@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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.<br>
<br>I found this solution: <a href="http://openlayers.org/pipermail/users/2009-March/010890.html" target="_blank">http://openlayers.org/pipermail/users/2009-March/010890.html</a> which partially explains OpenLayers.Function.bind() and gives another option of using the scope to set the parameter.<br>
<br>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".<br>
<br>This is what I have:<br><br>for (i in servers) {<br> OpenLayers.Request.issue({<br> url: servers[i],<br> headers: {...},<br> params: {...}<br> success: this.someFunction,<br> scope: this<br>
});<br>}<br><br>This is what I need:<br><br>for (i in servers) {<br>
OpenLayers.Request.issue({<br>
url: servers[i],<br>
headers: {...},<br>
params: {...}<br>
success: this.someFunction(i, response), // preset parameter "i"<br>
scope: this<br>
});<br>
}<br><br>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.<br><br>Thanks in advance.<br>
</blockquote></div><br>