Uncaught ReferenceError: takepic is not defined (Intel XDK)

0

I saw on the internet an example to capture photo in the app. I am debugging and this error appears:

  

Uncaught ReferenceError: takepic is not defined

My code:

function takepic(){
        intel.xdk.camera.takePicture(10,true, "jpg");
    }
    document.addEventListener("intel.xdk.camera.picture.add", function(event){
        var nomeFoto = event.filename;
        var url = intel.xdk.camera.getPictureURL(nomeFoto);
        document.getElementById("ocorrenciaFoto1").setAttribute("src", url);
    });

Button that does the action:

<button onclick="takepic()" class="btn widget uib_w_50 d-margins btn-lg btn-primary" data-uib="twitter%20bootstrap/button" data-ver="1"><i class="glyphicon glyphicon-camera button-icon-top" data-position="top"></i>Foto</button>

What's wrong?

    
asked by anonymous 19.12.2015 / 16:30

1 answer

1

Try this:

function takepic() {
  intel.xdk.camera.takePicture(10, true, "jpg");
}
document.addEventListener("intel.xdk.camera.picture.add", function(event) {
  var nomeFoto = event.filename;
  var url = intel.xdk.camera.getPictureURL(nomeFoto);
  document.getElementById("ocorrenciaFoto1").setAttribute("src", url);
});
var button = document.getElementById("takeAPicture");
button.addEventListener("click", takepic);

Add a id="takeAPicture" to your button and remove onclick="takepic()" .

    
19.12.2015 / 16:50