[Seaside] JQAutocomplete and #onAjaxStart:

Mariano Martinez Peck marianopeck at gmail.com
Wed Oct 29 19:14:23 UTC 2014

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20141029/cec31090/attachment.htm

More information about the seaside mailing list