What about js functions with names created on callbacks?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What about js functions with names created on callbacks?

sebastianconcept
Hi guys,

I'm aware that blockClousures map to js functions but how would you write in amber this piece of js code? [1]

function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
value: item.name
}
}));
 
sebastian

PD: that's needed for  was extracted from the autocomplete example here:
http://jqueryui.com/demos/autocomplete/#remote-jsonp

[1] if I'm understanding it right this piece of code seems to assign the response function to the autocomplete in the success callback. Isn't it?
Reply | Threaded
Open this post in threaded view
|

Re: What about js functions with names created on callbacks?

Nicolas Petton
Sebastian Sastre <[hidden email]> writes:

Hi Sebastian,

If I understand correctly, `response` is a callback function. Then I would write it this way (untested):

[ :data |
  response value: (jQuery map: data geonames callback: [ :items |
           .... ])]


HTH,
Nico

> Hi guys,
>
>
> I'm aware that blockClousures map to js functions but how would you
> write in amber this piece of js code? [1]
>
> function( data ) {
> response( $.map( data.geonames, function( item ) {
> return {
> label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") +
> ", " + item.countryName,
> value: item.name
> }
> }));
>  
> sebastian
>
> PD: that's needed for  was extracted from the autocomplete example
> here:
> http://jqueryui.com/demos/autocomplete/#remote-jsonp
>
> [1] if I'm understanding it right this piece of code seems to assign
> the response function to the autocomplete in the success callback.
> Isn't it?

--
Nicolas Petton
http://nicolas-petton.fr
Reply | Threaded
Open this post in threaded view
|

Re: What about js functions with names created on callbacks?

sebastianconcept
you're right it's a call to the response function that cames as arg in the ajax call

thanks for the light





Em segunda-feira, 4 de junho de 2012 08h56min01s UTC-3, nicolas petton escreveu:
Sebastian Sastre <[hidden email]> writes:

Hi Sebastian,

If I understand correctly, `response` is a callback function. Then I would write it this way (untested):

[ :data |
  response value: (jQuery map: data geonames callback: [ :items |
           .... ])]


HTH,
Nico

> Hi guys,
>
>
> I'm aware that blockClousures map to js functions but how would you
> write in amber this piece of js code? [1]
>
> function( data ) {
> response( $.map( data.geonames, function( item ) {
> return {
> label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") +
> ", " + item.countryName,
> value: item.name
> }
> }));
>  
> sebastian
>
> PD: that's needed for  was extracted from the autocomplete example
> here:
> http://jqueryui.com/demos/autocomplete/#remote-jsonp
>
> [1] if I'm understanding it right this piece of code seems to assign
> the response function to the autocomplete in the success callback.
> Isn't it?

--
Nicolas Petton
http://nicolas-petton.fr