[Seaside] Re: JQAutocomplete and #onAjaxStart:

Paul DeBruicker pdebruic at gmail.com
Wed Oct 29 23:24:46 UTC 2014


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

> seaside at .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.


More information about the seaside mailing list