This is a very annoying issue, I am using cordova with backbone to build hybrid solution, and I want user to select photo to upload. please see following code:
events:{ "click #btnPhotos": "getPhoto", "click #btnCamera": "capturePhoto" }, getPhoto: function() { // Retrieve image file location from specified source _self = this; alert (navigator.camera) alert (_self.uploadPhoto) navigator.camera.getPicture( _self.uploadPhoto, function(message){ util.alert('Failed to get pictures'); }, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY } ); }, uploadPhoto: function(imageURI) { alert ('got htere'); alert (imageURI) } this is part of code in a view, I want to trigger the function and the upload the selected photo. whenever I run, I checked LogCat, error is: 09-25 02:46:08.685: D/CordovaLog(8340): file:///android_asset/www/js/libs/backbone.js: Line 996 : Uncaught Error: Backbone.history has already been started I suspect that whenever user selected a photo, Cordova just simulate the click on Back button, but this action will trigger backbone route to be executed again. And the call back function never get called and I can never get the imageURI. If I move this out off backbone/requireJS, everything worked fine. I believe this is a very popular issue and many ones have used cordova with backbone/requireJS, how do you overcome this issue? Thanks in advance.