Improved AJAX bindung.
This commit is contained in:
parent
35d7a46ab6
commit
a557df0106
1 changed files with 10 additions and 5 deletions
|
@ -24,21 +24,26 @@ class _Singleton
|
||||||
|
|
||||||
constructor: (@args) ->
|
constructor: (@args) ->
|
||||||
|
|
||||||
|
# bindings
|
||||||
|
$('body').bind( 'ajaxSend', =>
|
||||||
|
@_show_spinner()
|
||||||
|
).bind( 'ajaxComplete', =>
|
||||||
|
@_hide_spinner()
|
||||||
|
)
|
||||||
|
|
||||||
ajax: (params, defaults) ->
|
ajax: (params, defaults) ->
|
||||||
data = $.extend({}, @defaults, defaults, params)
|
data = $.extend({}, @defaults, defaults, params)
|
||||||
@count++
|
|
||||||
@_show_spinner()
|
|
||||||
# console.log( 'START', @count )
|
|
||||||
if params['id']
|
if params['id']
|
||||||
if @queue_list[ params['id'] ]
|
if @queue_list[ params['id'] ]
|
||||||
@queue_list[ params['id'] ].abort()
|
@queue_list[ params['id'] ].abort()
|
||||||
@queue_list[ params['id'] ] = $.ajax( data ).always( @_hide_spinner )
|
@queue_list[ params['id'] ] = $.ajax( data )
|
||||||
else
|
else
|
||||||
$.ajax( data ).always( @_hide_spinner )
|
$.ajax( data )
|
||||||
|
|
||||||
console.log('AJAX', params['url'] )
|
console.log('AJAX', params['url'] )
|
||||||
|
|
||||||
_show_spinner: =>
|
_show_spinner: =>
|
||||||
|
@count++
|
||||||
$('.spinner').show()
|
$('.spinner').show()
|
||||||
|
|
||||||
_hide_spinner: =>
|
_hide_spinner: =>
|
||||||
|
|
Loading…
Reference in a new issue