保存Ember内容时更改鼠标光标 [英] Changing mouse cursor while Ember content is saving
本文介绍了保存Ember内容时更改鼠标光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道Ember可以很直接地显示需要很长时间的路线转换指示器。
I know Ember makes it quite straight forward to display an indicator on route transitions that take a long time.
但是,单击保存按钮后直到保存操作完成,最简单的方法是什么?我在此方面没有找到太多东西。
But what's the easiest way to do the same after a Save button is clicked, and until the save operation completes? I am not finding much on this.
推荐答案
感谢kingpin2k,我觉得此解决方案可以很好地处理EmberData Model ajax操作:
Thanks to kingpin2k, I feel this solution pretty nicely handles EmberData Model ajax operations:
DS.Model.reopen
save: ->
@cursorWait()
@_super().finally =>
@cursorDefault()
createRecord: (hash) ->
@cursorWait()
@_super(hash).finally =>
@cursorDefault()
destroyRecord: ->
@cursorWait()
@_super().finally =>
@cursorDefault()
cursorWait: ->
$('html,body').css('cursor', 'wait')
cursorDefault: ->
$('html,body').css('cursor', 'default')
并且在调用模型方法时,仍然可以链接 finally 和/或 then :
And one can still chain a finally and/or a then while calling the model methods:
actions:
save: ->
@controller.content.save().then(-> console.log 'then').finally(-> console.log 'another finally')
这篇关于保存Ember内容时更改鼠标光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文