JQAutocomplete and #onAjaxStart:

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

JQAutocomplete and #onAjaxStart:

Mariano Martinez Peck
Hi guys,

My app has a some code (thanks Esteban Lorenzano for sharing it with me) to show a little "Loading..." banner... That is:

renderAjaxLoadingDivOn: html
html 
div 
style: 'display:none';
class: 'loading';
script: (html jQuery this 
onAjaxStart: (html jQuery this show);
onAjaxStop: (html jQuery this hide));
with: 'Loading...'


Now...it works well for some explicit parts where I use ajax. However, it doesn't work for the JQAutocomplete. It my case, the callback to the autocomplete can take some seconds. It seems #onAjaxStart: is NOT intercepting what the autocomplete os doing. Could it be because autocomplete is doing a getJson actually? 

The key code of the autocomplete is:

search: aSearchBlock labels: aLabelsBlock callback: aCallbackBlock
"A one argument block aSearchBlock that will be evaluated with the term the user currently typed. The block is expected to answer a collection of objects. aLabelsBlock should answer a string label to be displayed for each object. aCallbackBlock is evaluated with the selected object and an ajax script to be performed."
| term mapping |
mapping := IdentityDictionary new.
"assigments to temps don't work in GS 2.4'
term := WAValueHolder new.
self source: ((self jQuery getJson
callback: [ :value | term contents: value ]
value: (JSStream on: 'request.term');
text: [ :stream | 
stream json: ((aSearchBlock value: term contents) asArray collect: [ :object | 
GRSmallDictionary new
at: 'label' put: (aLabelsBlock value: object);
at: 'index' put: (mapping at: object ifAbsentPut: [ mapping size + 1 ]);
yourself ]) ];
onSuccess: 'response(arguments[0])'; 
dataType: 'jsonp') asFunction: #('request' 'response')).
self onSelect: ((self jQuery ajax
callback: [ :value | term contents: value greaseInteger ] 
value: (JSStream on: 'ui.item.index');
script: [ :script |
mapping keysAndValuesDo: [ :object :value |
value = term contents
ifTrue: [ aCallbackBlock value: object value: script ] ] ])
asFunction: #('event' 'ui'))


Any help would be very appreciated.

Thanks, 

--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: JQAutocomplete and #onAjaxStart:

Paul DeBruicker
What jQuery version?

It might be because the #onAjaxStart: and #onAjaxStop: methods should only be set on the document for some jQuerys (e.g. >= version 1.8) see: http://api.jquery.com/ajaxStart/






Mariano Martinez Peck wrote
Hi guys,

My app has a some code (thanks Esteban Lorenzano for sharing it with me) to
show a little "Loading..." banner... That is:

renderAjaxLoadingDivOn: html
html
div
style: 'display:none';
class: 'loading';
script: (html jQuery this
onAjaxStart: (html jQuery this show);
onAjaxStop: (html jQuery this hide));
with: 'Loading...'


Now...it works well for some explicit parts where I use ajax. However, it
doesn't work for the JQAutocomplete. It my case, the callback to the
autocomplete can take some seconds. It seems #onAjaxStart: is NOT
intercepting what the autocomplete os doing. Could it be because
autocomplete is doing a getJson actually?

The key code of the autocomplete is:

search: aSearchBlock labels: aLabelsBlock callback: aCallbackBlock
"A one argument block aSearchBlock that will be evaluated with the term the
user currently typed. The block is expected to answer a collection of
objects. aLabelsBlock should answer a string label to be displayed for each
object. aCallbackBlock is evaluated with the selected object and an ajax
script to be performed."
 | term mapping |
mapping := IdentityDictionary new.
"assigments to temps don't work in GS 2.4'
http://code.google.com/p/glassdb/issues/detail?id=221"
term := WAValueHolder new.
self source: ((self jQuery getJson
callback: [ :value | term contents: value ]
value: (JSStream on: 'request.term');
text: [ :stream |
stream json: ((aSearchBlock value: term contents) asArray collect: [
:object |
GRSmallDictionary new
at: 'label' put: (aLabelsBlock value: object);
at: 'index' put: (mapping at: object ifAbsentPut: [ mapping size + 1 ]);
yourself ]) ];
onSuccess: 'response(arguments[0])';
dataType: 'jsonp') asFunction: #('request' 'response')).
self onSelect: ((self jQuery ajax
callback: [ :value | term contents: value greaseInteger ]
value: (JSStream on: 'ui.item.index');
script: [ :script |
mapping keysAndValuesDo: [ :object :value |
value = term contents
ifTrue: [ aCallbackBlock value: object value: script ] ] ])
asFunction: #('event' 'ui'))


Any help would be very appreciated.

Thanks,

--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: JQAutocomplete and #onAjaxStart:

Mariano Martinez Peck


On Wed, Oct 29, 2014 at 8:24 PM, Paul DeBruicker <[hidden email]> wrote:
What jQuery version?

It might be because the #onAjaxStart: and #onAjaxStop: methods should only
be set on the document for some jQuerys (e.g. >= version 1.8) see:
http://api.jquery.com/ajaxStart/


Thanks Paul. I am using 1.11.0. So if I understand what you mean, I guess I should do instead:

html 
div 
style: 'display:none';
class: 'quuveLoading';
script: (html jQuery document 
onAjaxStart: (html jQuery this show);
onAjaxStop: (html jQuery this hide));
with: 'Loading...'
 

right? still not working thought :(

I tried even a simple 'alert(''aa'');' but still not getting called..

Thanks anyway. 
 




Mariano Martinez Peck wrote
> Hi guys,
>
> My app has a some code (thanks Esteban Lorenzano for sharing it with me)
> to
> show a little "Loading..." banner... That is:
>
> renderAjaxLoadingDivOn: html
> html
> div
> style: 'display:none';
> class: 'loading';
> script: (html jQuery this
> onAjaxStart: (html jQuery this show);
> onAjaxStop: (html jQuery this hide));
> with: 'Loading...'
>
>
> Now...it works well for some explicit parts where I use ajax. However, it
> doesn't work for the JQAutocomplete. It my case, the callback to the
> autocomplete can take some seconds. It seems #onAjaxStart: is NOT
> intercepting what the autocomplete os doing. Could it be because
> autocomplete is doing a getJson actually?
>
> The key code of the autocomplete is:
>
> search: aSearchBlock labels: aLabelsBlock callback: aCallbackBlock
> "A one argument block aSearchBlock that will be evaluated with the term
> the
> user currently typed. The block is expected to answer a collection of
> objects. aLabelsBlock should answer a string label to be displayed for
> each
> object. aCallbackBlock is evaluated with the selected object and an ajax
> script to be performed."
>  | term mapping |
> mapping := IdentityDictionary new.
> "assigments to temps don't work in GS 2.4'
> http://code.google.com/p/glassdb/issues/detail?id=221"
> term := WAValueHolder new.
> self source: ((self jQuery getJson
> callback: [ :value | term contents: value ]
> value: (JSStream on: 'request.term');
> text: [ :stream |
> stream json: ((aSearchBlock value: term contents) asArray collect: [
> :object |
> GRSmallDictionary new
> at: 'label' put: (aLabelsBlock value: object);
> at: 'index' put: (mapping at: object ifAbsentPut: [ mapping size + 1 ]);
> yourself ]) ];
> onSuccess: 'response(arguments[0])';
> dataType: 'jsonp') asFunction: #('request' 'response')).
> self onSelect: ((self jQuery ajax
> callback: [ :value | term contents: value greaseInteger ]
> value: (JSStream on: 'ui.item.index');
> script: [ :script |
> mapping keysAndValuesDo: [ :object :value |
> value = term contents
> ifTrue: [ aCallbackBlock value: object value: script ] ] ])
> asFunction: #('event' 'ui'))
>
>
> Any help would be very appreciated.
>
> Thanks,
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> _______________________________________________
> seaside mailing list

> seaside@.squeakfoundation

> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside





--
View this message in context: http://forum.world.st/JQAutocomplete-and-onAjaxStart-tp4787505p4787543.html
Sent from the Seaside General mailing list archive at Nabble.com.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: JQAutocomplete and #onAjaxStart:

Esteban A. Maringolo
I don't know for autocomplete, but a long time ago I implemented that like this:

html document addLoadScript: (JSStream on:
'$(document).ajaxComplete(function() {$("#xhrstatus").hide();})').
html document addLoadScript: (JSStream on:
'$(document).ajaxStart(function() {$("#xhrstatus").show();})').

And it works well. I could refactor it, but because it works...
Esteban A. Maringolo


2014-10-29 22:35 GMT-03:00 Mariano Martinez Peck <[hidden email]>:

>
>
> On Wed, Oct 29, 2014 at 8:24 PM, Paul DeBruicker <[hidden email]> wrote:
>>
>> What jQuery version?
>>
>> It might be because the #onAjaxStart: and #onAjaxStop: methods should only
>> be set on the document for some jQuerys (e.g. >= version 1.8) see:
>> http://api.jquery.com/ajaxStart/
>>
>
> Thanks Paul. I am using 1.11.0. So if I understand what you mean, I guess I
> should do instead:
>
> html
> div
> style: 'display:none';
> class: 'quuveLoading';
> script: (html jQuery document
> onAjaxStart: (html jQuery this show);
> onAjaxStop: (html jQuery this hide));
> with: 'Loading...'
>
>
> right? still not working thought :(
>
> I tried even a simple 'alert(''aa'');' but still not getting called..
>
> Thanks anyway.
>
>>
>>
>>
>>
>>
>> Mariano Martinez Peck wrote
>> > Hi guys,
>> >
>> > My app has a some code (thanks Esteban Lorenzano for sharing it with me)
>> > to
>> > show a little "Loading..." banner... That is:
>> >
>> > renderAjaxLoadingDivOn: html
>> > html
>> > div
>> > style: 'display:none';
>> > class: 'loading';
>> > script: (html jQuery this
>> > onAjaxStart: (html jQuery this show);
>> > onAjaxStop: (html jQuery this hide));
>> > with: 'Loading...'
>> >
>> >
>> > Now...it works well for some explicit parts where I use ajax. However,
>> > it
>> > doesn't work for the JQAutocomplete. It my case, the callback to the
>> > autocomplete can take some seconds. It seems #onAjaxStart: is NOT
>> > intercepting what the autocomplete os doing. Could it be because
>> > autocomplete is doing a getJson actually?
>> >
>> > The key code of the autocomplete is:
>> >
>> > search: aSearchBlock labels: aLabelsBlock callback: aCallbackBlock
>> > "A one argument block aSearchBlock that will be evaluated with the term
>> > the
>> > user currently typed. The block is expected to answer a collection of
>> > objects. aLabelsBlock should answer a string label to be displayed for
>> > each
>> > object. aCallbackBlock is evaluated with the selected object and an ajax
>> > script to be performed."
>> >  | term mapping |
>> > mapping := IdentityDictionary new.
>> > "assigments to temps don't work in GS 2.4'
>> > http://code.google.com/p/glassdb/issues/detail?id=221"
>> > term := WAValueHolder new.
>> > self source: ((self jQuery getJson
>> > callback: [ :value | term contents: value ]
>> > value: (JSStream on: 'request.term');
>> > text: [ :stream |
>> > stream json: ((aSearchBlock value: term contents) asArray collect: [
>> > :object |
>> > GRSmallDictionary new
>> > at: 'label' put: (aLabelsBlock value: object);
>> > at: 'index' put: (mapping at: object ifAbsentPut: [ mapping size + 1 ]);
>> > yourself ]) ];
>> > onSuccess: 'response(arguments[0])';
>> > dataType: 'jsonp') asFunction: #('request' 'response')).
>> > self onSelect: ((self jQuery ajax
>> > callback: [ :value | term contents: value greaseInteger ]
>> > value: (JSStream on: 'ui.item.index');
>> > script: [ :script |
>> > mapping keysAndValuesDo: [ :object :value |
>> > value = term contents
>> > ifTrue: [ aCallbackBlock value: object value: script ] ] ])
>> > asFunction: #('event' 'ui'))
>> >
>> >
>> > Any help would be very appreciated.
>> >
>> > Thanks,
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> > _______________________________________________
>> > seaside mailing list
>>
>> > seaside@.squeakfoundation
>>
>> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://forum.world.st/JQAutocomplete-and-onAjaxStart-tp4787505p4787543.html
>> Sent from the Seaside General mailing list archive at Nabble.com.
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: JQAutocomplete and #onAjaxStart:

Mariano Martinez Peck


On Wed, Oct 29, 2014 at 10:39 PM, Esteban A. Maringolo <[hidden email]> wrote:
I don't know for autocomplete, but a long time ago I implemented that like this:

html document addLoadScript: (JSStream on:
'$(document).ajaxComplete(function() {$("#xhrstatus").hide();})').
html document addLoadScript: (JSStream on:
'$(document).ajaxStart(function() {$("#xhrstatus").show();})').

And it works well. I could refactor it, but because it works...

WTF! that worked!! Thanks Esteban! This works for me:

renderAjaxLoadingDivOn: html
html 
div 
style: 'display:none';
id: 'loading';
class: 'loading';
with: 'Loading...'.
html document addLoadScript: (JSStream on:
'$(document).ajaxComplete(function() {$("#loading").hide();})').
html document addLoadScript: (JSStream on:
'$(document).ajaxStart(function() {$("#loading").show();})').
 


does anyone know what is the difference or why this one works while the other does not?

Thanks Esteban.


Esteban A. Maringolo


2014-10-29 22:35 GMT-03:00 Mariano Martinez Peck <[hidden email]>:
>
>
> On Wed, Oct 29, 2014 at 8:24 PM, Paul DeBruicker <[hidden email]> wrote:
>>
>> What jQuery version?
>>
>> It might be because the #onAjaxStart: and #onAjaxStop: methods should only
>> be set on the document for some jQuerys (e.g. >= version 1.8) see:
>> http://api.jquery.com/ajaxStart/
>>
>
> Thanks Paul. I am using 1.11.0. So if I understand what you mean, I guess I
> should do instead:
>
> html
> div
> style: 'display:none';
> class: 'quuveLoading';
> script: (html jQuery document
> onAjaxStart: (html jQuery this show);
> onAjaxStop: (html jQuery this hide));
> with: 'Loading...'
>
>
> right? still not working thought :(
>
> I tried even a simple 'alert(''aa'');' but still not getting called..
>
> Thanks anyway.
>
>>
>>
>>
>>
>>
>> Mariano Martinez Peck wrote
>> > Hi guys,
>> >
>> > My app has a some code (thanks Esteban Lorenzano for sharing it with me)
>> > to
>> > show a little "Loading..." banner... That is:
>> >
>> > renderAjaxLoadingDivOn: html
>> > html
>> > div
>> > style: 'display:none';
>> > class: 'loading';
>> > script: (html jQuery this
>> > onAjaxStart: (html jQuery this show);
>> > onAjaxStop: (html jQuery this hide));
>> > with: 'Loading...'
>> >
>> >
>> > Now...it works well for some explicit parts where I use ajax. However,
>> > it
>> > doesn't work for the JQAutocomplete. It my case, the callback to the
>> > autocomplete can take some seconds. It seems #onAjaxStart: is NOT
>> > intercepting what the autocomplete os doing. Could it be because
>> > autocomplete is doing a getJson actually?
>> >
>> > The key code of the autocomplete is:
>> >
>> > search: aSearchBlock labels: aLabelsBlock callback: aCallbackBlock
>> > "A one argument block aSearchBlock that will be evaluated with the term
>> > the
>> > user currently typed. The block is expected to answer a collection of
>> > objects. aLabelsBlock should answer a string label to be displayed for
>> > each
>> > object. aCallbackBlock is evaluated with the selected object and an ajax
>> > script to be performed."
>> >  | term mapping |
>> > mapping := IdentityDictionary new.
>> > "assigments to temps don't work in GS 2.4'
>> > http://code.google.com/p/glassdb/issues/detail?id=221"
>> > term := WAValueHolder new.
>> > self source: ((self jQuery getJson
>> > callback: [ :value | term contents: value ]
>> > value: (JSStream on: 'request.term');
>> > text: [ :stream |
>> > stream json: ((aSearchBlock value: term contents) asArray collect: [
>> > :object |
>> > GRSmallDictionary new
>> > at: 'label' put: (aLabelsBlock value: object);
>> > at: 'index' put: (mapping at: object ifAbsentPut: [ mapping size + 1 ]);
>> > yourself ]) ];
>> > onSuccess: 'response(arguments[0])';
>> > dataType: 'jsonp') asFunction: #('request' 'response')).
>> > self onSelect: ((self jQuery ajax
>> > callback: [ :value | term contents: value greaseInteger ]
>> > value: (JSStream on: 'ui.item.index');
>> > script: [ :script |
>> > mapping keysAndValuesDo: [ :object :value |
>> > value = term contents
>> > ifTrue: [ aCallbackBlock value: object value: script ] ] ])
>> > asFunction: #('event' 'ui'))
>> >
>> >
>> > Any help would be very appreciated.
>> >
>> > Thanks,
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> > _______________________________________________
>> > seaside mailing list
>>
>> > seaside@.squeakfoundation
>>
>> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://forum.world.st/JQAutocomplete-and-onAjaxStart-tp4787505p4787543.html
>> Sent from the Seaside General mailing list archive at Nabble.com.
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: JQAutocomplete and #onAjaxStart:

Paul DeBruicker
Don't know for sure.  Do you send #onAjaxStart: anyplace else?


Just for another example - the way I do it is in the footer of my app:

renderAddLoadScripts: html
        html document
                addLoadScript:
                        (html jQuery document
                                onAjaxStart: (html jQuery class: #spinner) show;
                                onAjaxStop: (html jQuery class: #spinner) hide;
                                onAjaxError: (self ajaxErrorHandler asFunction: #('event' 'jqxhr' 'settings' 'exception')))





Mariano Martinez Peck wrote
On Wed, Oct 29, 2014 at 10:39 PM, Esteban A. Maringolo <[hidden email]
> wrote:

> I don't know for autocomplete, but a long time ago I implemented that like
> this:
>
> html document addLoadScript: (JSStream on:
> '$(document).ajaxComplete(function() {$("#xhrstatus").hide();})').
> html document addLoadScript: (JSStream on:
> '$(document).ajaxStart(function() {$("#xhrstatus").show();})').
>
> And it works well. I could refactor it, but because it works...
>

WTF! that worked!! Thanks Esteban! This works for me:

renderAjaxLoadingDivOn: html
html
div
style: 'display:none';
id: 'loading';
class: 'loading';
with: 'Loading...'.
html document addLoadScript: (JSStream on:
'$(document).ajaxComplete(function() {$("#loading").hide();})').
html document addLoadScript: (JSStream on:
'$(document).ajaxStart(function() {$("#loading").show();})').



does anyone know what is the difference or why this one works while the
other does not?

Thanks Esteban.


Esteban A. Maringolo
>
>
> 2014-10-29 22:35 GMT-03:00 Mariano Martinez Peck <[hidden email]>:
> >
> >
> > On Wed, Oct 29, 2014 at 8:24 PM, Paul DeBruicker <[hidden email]>
> wrote:
> >>
> >> What jQuery version?
> >>
> >> It might be because the #onAjaxStart: and #onAjaxStop: methods should
> only
> >> be set on the document for some jQuerys (e.g. >= version 1.8) see:
> >> http://api.jquery.com/ajaxStart/
> >>
> >
> > Thanks Paul. I am using 1.11.0. So if I understand what you mean, I
> guess I
> > should do instead:
> >
> > html
> > div
> > style: 'display:none';
> > class: 'quuveLoading';
> > script: (html jQuery document
> > onAjaxStart: (html jQuery this show);
> > onAjaxStop: (html jQuery this hide));
> > with: 'Loading...'
> >
> >
> > right? still not working thought :(
> >
> > I tried even a simple 'alert(''aa'');' but still not getting called..
> >
> > Thanks anyway.
> >
> >>
> >>
> >>
> >>
> >>
> >> Mariano Martinez Peck wrote
> >> > Hi guys,
> >> >
> >> > My app has a some code (thanks Esteban Lorenzano for sharing it with
> me)
> >> > to
> >> > show a little "Loading..." banner... That is:
> >> >
> >> > renderAjaxLoadingDivOn: html
> >> > html
> >> > div
> >> > style: 'display:none';
> >> > class: 'loading';
> >> > script: (html jQuery this
> >> > onAjaxStart: (html jQuery this show);
> >> > onAjaxStop: (html jQuery this hide));
> >> > with: 'Loading...'
> >> >
> >> >
> >> > Now...it works well for some explicit parts where I use ajax. However,
> >> > it
> >> > doesn't work for the JQAutocomplete. It my case, the callback to the
> >> > autocomplete can take some seconds. It seems #onAjaxStart: is NOT
> >> > intercepting what the autocomplete os doing. Could it be because
> >> > autocomplete is doing a getJson actually?
> >> >
> >> > The key code of the autocomplete is:
> >> >
> >> > search: aSearchBlock labels: aLabelsBlock callback: aCallbackBlock
> >> > "A one argument block aSearchBlock that will be evaluated with the
> term
> >> > the
> >> > user currently typed. The block is expected to answer a collection of
> >> > objects. aLabelsBlock should answer a string label to be displayed for
> >> > each
> >> > object. aCallbackBlock is evaluated with the selected object and an
> ajax
> >> > script to be performed."
> >> >  | term mapping |
> >> > mapping := IdentityDictionary new.
> >> > "assigments to temps don't work in GS 2.4'
> >> > http://code.google.com/p/glassdb/issues/detail?id=221"
> >> > term := WAValueHolder new.
> >> > self source: ((self jQuery getJson
> >> > callback: [ :value | term contents: value ]
> >> > value: (JSStream on: 'request.term');
> >> > text: [ :stream |
> >> > stream json: ((aSearchBlock value: term contents) asArray collect: [
> >> > :object |
> >> > GRSmallDictionary new
> >> > at: 'label' put: (aLabelsBlock value: object);
> >> > at: 'index' put: (mapping at: object ifAbsentPut: [ mapping size + 1
> ]);
> >> > yourself ]) ];
> >> > onSuccess: 'response(arguments[0])';
> >> > dataType: 'jsonp') asFunction: #('request' 'response')).
> >> > self onSelect: ((self jQuery ajax
> >> > callback: [ :value | term contents: value greaseInteger ]
> >> > value: (JSStream on: 'ui.item.index');
> >> > script: [ :script |
> >> > mapping keysAndValuesDo: [ :object :value |
> >> > value = term contents
> >> > ifTrue: [ aCallbackBlock value: object value: script ] ] ])
> >> > asFunction: #('event' 'ui'))
> >> >
> >> >
> >> > Any help would be very appreciated.
> >> >
> >> > Thanks,
> >> >
> >> > --
> >> > Mariano
> >> > http://marianopeck.wordpress.com
> >> >
> >> > _______________________________________________
> >> > seaside mailing list
> >>
> >> > seaside@.squeakfoundation
> >>
> >> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >>
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://forum.world.st/JQAutocomplete-and-onAjaxStart-tp4787505p4787543.html
> >> Sent from the Seaside General mailing list archive at Nabble.com.
> >> _______________________________________________
> >> seaside mailing list
> >> [hidden email]
> >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
> >
> >
> >
> > --
> > Mariano
> > http://marianopeck.wordpress.com
> >
> > _______________________________________________
> > seaside mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: JQAutocomplete and #onAjaxStart:

Mariano Martinez Peck


On Wed, Oct 29, 2014 at 11:16 PM, Paul DeBruicker <[hidden email]> wrote:
Don't know for sure.  Do you send #onAjaxStart: anyplace else?


Just for another example - the way I do it is in the footer of my app:

renderAddLoadScripts: html
        html document
                addLoadScript:
                        (html jQuery document
                                onAjaxStart: (html jQuery class: #spinner) show;
                                onAjaxStop: (html jQuery class: #spinner) hide;
                                onAjaxError: (self ajaxErrorHandler asFunction: #('event' 'jqxhr'
'settings' 'exception')))



Interesting. Could you share the #ajaxErrorHandler? 
 




Mariano Martinez Peck wrote
> On Wed, Oct 29, 2014 at 10:39 PM, Esteban A. Maringolo &lt;

> emaringolo@

> &gt; wrote:
>
>> I don't know for autocomplete, but a long time ago I implemented that
>> like
>> this:
>>
>> html document addLoadScript: (JSStream on:
>> '$(document).ajaxComplete(function() {$("#xhrstatus").hide();})').
>> html document addLoadScript: (JSStream on:
>> '$(document).ajaxStart(function() {$("#xhrstatus").show();})').
>>
>> And it works well. I could refactor it, but because it works...
>>
>
> WTF! that worked!! Thanks Esteban! This works for me:
>
> renderAjaxLoadingDivOn: html
> html
> div
> style: 'display:none';
> id: 'loading';
> class: 'loading';
> with: 'Loading...'.
> html document addLoadScript: (JSStream on:
> '$(document).ajaxComplete(function() {$("#loading").hide();})').
> html document addLoadScript: (JSStream on:
> '$(document).ajaxStart(function() {$("#loading").show();})').
>
>
>
> does anyone know what is the difference or why this one works while the
> other does not?
>
> Thanks Esteban.
>
>
> Esteban A. Maringolo
>>
>>
>> 2014-10-29 22:35 GMT-03:00 Mariano Martinez Peck &lt;

> marianopeck@

> &gt;:
>> >
>> >
>> > On Wed, Oct 29, 2014 at 8:24 PM, Paul DeBruicker &lt;

> pdebruic@

> &gt;
>> wrote:
>> >>
>> >> What jQuery version?
>> >>
>> >> It might be because the #onAjaxStart: and #onAjaxStop: methods should
>> only
>> >> be set on the document for some jQuerys (e.g. >= version 1.8) see:
>> >> http://api.jquery.com/ajaxStart/
>> >>
>> >
>> > Thanks Paul. I am using 1.11.0. So if I understand what you mean, I
>> guess I
>> > should do instead:
>> >
>> > html
>> > div
>> > style: 'display:none';
>> > class: 'quuveLoading';
>> > script: (html jQuery document
>> > onAjaxStart: (html jQuery this show);
>> > onAjaxStop: (html jQuery this hide));
>> > with: 'Loading...'
>> >
>> >
>> > right? still not working thought :(
>> >
>> > I tried even a simple 'alert(''aa'');' but still not getting called..
>> >
>> > Thanks anyway.
>> >
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Mariano Martinez Peck wrote
>> >> > Hi guys,
>> >> >
>> >> > My app has a some code (thanks Esteban Lorenzano for sharing it with
>> me)
>> >> > to
>> >> > show a little "Loading..." banner... That is:
>> >> >
>> >> > renderAjaxLoadingDivOn: html
>> >> > html
>> >> > div
>> >> > style: 'display:none';
>> >> > class: 'loading';
>> >> > script: (html jQuery this
>> >> > onAjaxStart: (html jQuery this show);
>> >> > onAjaxStop: (html jQuery this hide));
>> >> > with: 'Loading...'
>> >> >
>> >> >
>> >> > Now...it works well for some explicit parts where I use ajax.
>> However,
>> >> > it
>> >> > doesn't work for the JQAutocomplete. It my case, the callback to the
>> >> > autocomplete can take some seconds. It seems #onAjaxStart: is NOT
>> >> > intercepting what the autocomplete os doing. Could it be because
>> >> > autocomplete is doing a getJson actually?
>> >> >
>> >> > The key code of the autocomplete is:
>> >> >
>> >> > search: aSearchBlock labels: aLabelsBlock callback: aCallbackBlock
>> >> > "A one argument block aSearchBlock that will be evaluated with the
>> term
>> >> > the
>> >> > user currently typed. The block is expected to answer a collection
>> of
>> >> > objects. aLabelsBlock should answer a string label to be displayed
>> for
>> >> > each
>> >> > object. aCallbackBlock is evaluated with the selected object and an
>> ajax
>> >> > script to be performed."
>> >> >  | term mapping |
>> >> > mapping := IdentityDictionary new.
>> >> > "assigments to temps don't work in GS 2.4'
>> >> > http://code.google.com/p/glassdb/issues/detail?id=221"
>> >> > term := WAValueHolder new.
>> >> > self source: ((self jQuery getJson
>> >> > callback: [ :value | term contents: value ]
>> >> > value: (JSStream on: 'request.term');
>> >> > text: [ :stream |
>> >> > stream json: ((aSearchBlock value: term contents) asArray collect: [
>> >> > :object |
>> >> > GRSmallDictionary new
>> >> > at: 'label' put: (aLabelsBlock value: object);
>> >> > at: 'index' put: (mapping at: object ifAbsentPut: [ mapping size + 1
>> ]);
>> >> > yourself ]) ];
>> >> > onSuccess: 'response(arguments[0])';
>> >> > dataType: 'jsonp') asFunction: #('request' 'response')).
>> >> > self onSelect: ((self jQuery ajax
>> >> > callback: [ :value | term contents: value greaseInteger ]
>> >> > value: (JSStream on: 'ui.item.index');
>> >> > script: [ :script |
>> >> > mapping keysAndValuesDo: [ :object :value |
>> >> > value = term contents
>> >> > ifTrue: [ aCallbackBlock value: object value: script ] ] ])
>> >> > asFunction: #('event' 'ui'))
>> >> >
>> >> >
>> >> > Any help would be very appreciated.
>> >> >
>> >> > Thanks,
>> >> >
>> >> > --
>> >> > Mariano
>> >> > http://marianopeck.wordpress.com
>> >> >
>> >> > _______________________________________________
>> >> > seaside mailing list
>> >>
>> >> > seaside@.squeakfoundation
>> >>
>> >> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://forum.world.st/JQAutocomplete-and-onAjaxStart-tp4787505p4787543.html
>> >> Sent from the Seaside General mailing list archive at Nabble.com.
>> >> _______________________________________________
>> >> seaside mailing list
>> >>

> seaside@.squeakfoundation

>> >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >
>> >
>> >
>> >
>> > --
>> > Mariano
>> > http://marianopeck.wordpress.com
>> >
>> > _______________________________________________
>> > seaside mailing list
>> >

> seaside@.squeakfoundation

>> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >
>> _______________________________________________
>> seaside mailing list
>>

> seaside@.squeakfoundation

>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
> _______________________________________________
> seaside mailing list

> seaside@.squeakfoundation

> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside





--
View this message in context: http://forum.world.st/JQAutocomplete-and-onAjaxStart-tp4787505p4787555.html
Sent from the Seaside General mailing list archive at Nabble.com.
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



--
Mariano
http://marianopeck.wordpress.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside