cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank He <>
Subject cordova camera.getpicture is not working with backbone/requireJS
Date Fri, 26 Sep 2014 07:40:05 GMT
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:

            "click #btnPhotos": "getPhoto",
            "click #btnCamera": "capturePhoto"

   getPhoto: function() {
             // Retrieve image file location from specified source
             _self = this;
             alert (
             alert (_self.uploadPhoto)
                             util.alert('Failed to get pictures');
                             quality: 50,
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.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message