23303

Changing mouse cursor while Ember content is saving

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.

Answer1:

Assuming based off the tag you are using ember data

$('html,body').css('cursor','crosshair'); record.save().finally(function(){ // revert mouse });

http://emberjs.com/api/classes/Ember.RSVP.Promise.html#method_finally

Obviously this is limited, and crosshair, but it shows the general idea, and typing in a phone sucks, I apologize.

Answer2:

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')

And one can still chain a <strong>finally</strong> and/or a <strong>then</strong> while calling the model methods:

actions: save: -> @controller.content.save().then(-> console.log 'then').finally(-> console.log 'another finally')

Recommend

  • get src from draggable img
  • Detail View on Storyboard too zoomed in - creates misaligned objects in simulator
  • R plotly, normal cursor when mouse over the plot
  • HTML select, correct option selected in DOM, but wrong item shown in firefox
  • In an Ember view, what's the best way to run code after the rerendering of an internal child vi
  • Ember.js Acceptance Testing not waiting for asynchronous data operations
  • How to restrict number of concurrent processes?
  • Use query params of parent route to refresh the model in subroute
  • Selenium and Google - How do you use cookies?
  • Query timeout expired in django-mssql when executing custom SQL directly
  • Use neo4j server instead of embedded mode
  • Pre-populated SQLite Database not reading properly in Android Studio
  • Converting query results into DataFrame in python
  • Possible to get mouse events fired when cursor is outside page?
  • How to remove a SwiftyJSON element?
  • Adjust width of select element according to selected option's width
  • Set matplotlib plot axis to be the dataframe column name
  • How can the INSERT … ON CONFLICT (id) DO UPDATE… syntax be used with a sequence ID?
  • Marklogic : Query response time is very high
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • Play WS (2.2.1): post/put large request
  • Why querying a date BC is changed to AD in Java?
  • Record samples being played with OpenAL
  • Modifying destination and filename of gulp-svg-sprite
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How to get icons for entities from eclipse?
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • embed rChart in Markdown
  • Change div Background jquery
  • JaxB to read class hierarchy
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Binding checkboxes to object values in AngularJs
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • Unable to use reactive element in my shiny app
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?