The jQuery ajax method does not implement the full promise interface; it
does not call notify and so the progress callback cannot work. As a
substitute, we pass the progress callback as the beforeSend callback,
which is executed before an ajax send.
Also, we use a progress bar instead of a progress text message.
Signed-off-by: Steven Chan <steven3416@gmail.com>
# Make an API call
action = @options._action
- od.api action.href, action.method, fields: $('form', @element).serializeArray()
-
- # TODO progress message is not showing
- # seems like the progress callback is never called
- .progress => @set_message 'progress', true
+ progress = => @set_message 'progress', true
+ od.api action.href, action.method, fields: $('form', @element).serializeArray(), progress
# Re-use the dialog to show notifications with a close button
.then(
# Customize the plain jQuery ajax method to handle a GET or POST method
# for the Overdrive api.
- api: (url, method, data) ->
+ api: (url, method, data, beforeSend) ->
# Do some pre-processing of data before it is sent to server
if method is 'post'
# A given data object is expected to be in JSON format
contentType: 'application/json; charset=utf-8'
data: json.stringify data
+ beforeSend: beforeSend
.done ->