4

I'm developing phonegap/cordova apps with ember. To use the backbutton functionality from android, it's important to send the "backbutton" event to my ember-App. How do I send an event to an ember application?

Enrico
  • 81
  • 1
  • 3

2 Answers2

1

I found this ember-specific mixin very useful. Give it a try, Ember bindings for using phonegap events.

Sheba
  • 726
  • 7
  • 16
1

I had faced this problem recently. I attached the backbutton eventlistener on 'didInsertElement' event in my Ember View.

App.IndexView = Ember.View.extend({
   _eventonInsert : function () {
      document.addEventListener('deviceready', function(e) {
         document.addEventListener('backbutton', function(e) {
             //Your logic related to back button
         });
      });
   }.on('didInsertElement')
});
Saba
  • 3,418
  • 2
  • 21
  • 34
  • I'm struggling with how to handle this with Cordova's `pause` event. This solution looks promising, but how do you 'unbind' or remove the handler from document when the view is erased? Since you're registering an anonymous function, each time this route is reloaded you're going to add another event listener. – StickByAtlas Feb 08 '16 at 16:10