on 07-25-2016 4:26 PM
Hi experts,
here i am working on camera functionality.
i have image control in view and button, when i click on button image should place in image control.
for this functionality i listed below. but here i am facing the issue with var oView = this.getView();
When i running the application it is showing "Uncaught TypeError: Cannot read property 'getView' of null".
if var oView = this.getView(); is outside of the onPhotoDataSuccess call back function, oView is getting instance of the view, but it is not getting in call back function of onPhotoDataSuccess.
can any one suggest how can i get view reference in onPhotoDataSuccess function.
and tell me any other alternate solution for this.
Detail.view.xml:
<Image id="myImage" width="200px" height="200px" />
<Button text="get photo" press="capturePhoto" />
Detail.controller.js:
capturePhoto : function() {
var oNav = navigator.camera;
oNav.getPicture(this.onPhotoDataSuccess, this.onFail, { quality: 10, destinationType: oNav.DestinationType.DATA_URL });
this._getDialog1().close();
}
onPhotoDataSuccess : function(imageData) {
var oView = this.getView(); // error in this line
var img = oView.byId("myImage");
img.setSrc("data:image/jpeg;base64," + imageData);
MessageToast.show("Photo have been Added Successfully");
}
put this.onPhotoDataSuccess.bind(this) in capturePhoto
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rangaswamy,
Try something like below:
capturePhoto : function() {
var oNav = navigator.camera;
oNav.getPicture($.proxy(this.onPhotoDataSuccess, this), $.proxy(this.onFail, this), { quality: 10, destinationType: oNav.DestinationType.DATA_URL });
this._getDialog1().close();
}
Regards,
Sai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.