If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
barlowdot1
Posts: 35
Registered: ‎02-06-2011
My Device: bold 9900
My Carrier: Vodacom
Accepted Solution

Dialog API doesn't return value on DevAlpha A

Hi, Im implementing customAskAsync with button D_YES_NO. I am alerting index in  dialogCallBack(index) when yes or no is clicked on the dialog. When I test with Ripple on Chrome, I get the correct values. When I package and test on DevAlpha A, I dont get any values returned. In the alert all I get is [object Object] that is being returned? I have simplified the code below.

function confirmationDialogPurge(message, dialogTitle) {
	try {
		blackberry.ui.dialog.standardAskAsync(message, 
			blackberry.ui.dialog.D_YES_NO, confirmationPurgeTable, {
			title : dialogTitle,
			size : blackberry.ui.dialog.SIZE_LARGE,
			position : blackberry.ui.dialog.CENTER
		});
	} catch (e) {
		alert("Exception in standardDialog: " + e);
	}
}
function confirmationPurgeTable(index){
	alert(index);
}

 

Please use plain text.
Developer
barlowdot1
Posts: 35
Registered: ‎02-06-2011
My Device: bold 9900
My Carrier: Vodacom

Re: Dialog API doesn't return value on DevAlpha A

Im not sure if this problem in only on the DevAlpha A? Is there someone out there who have a DevAlpha B or Z10, that is willing to test, I will send you the bar file. Please contact me on fbrown@negatron.co.za

Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: Dialog API doesn't return value on DevAlpha A

Hello,

 

This is working fine on my device with your code, running the latest public build .261

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: Dialog API doesn't return value on DevAlpha A

Sorry I'm wrong.

 

It works, BUT, it's returning an Object.

 

Object {return: "Yes"}

 

So you'll want to use something like this in your callback function

 

function confirmationPurgeTable(index){
   var button = index.return;
}

 

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Developer
barlowdot1
Posts: 35
Registered: ‎02-06-2011
My Device: bold 9900
My Carrier: Vodacom

Re: Dialog API doesn't return value on DevAlpha A

Chadtaro, Im not clear on your response. Based on what the user have selected in the dialog, the callback should either return 0 or 1. Dev Alpha A doesnt do that, but returns [object Object].

 

I'm not sure how "var button = index.return" helps me? as I need to do the following based on user selection.

 

function confirmationPurgeTable(index){
   if(index == 0){
      DO SOMETHING
   }else{
   DO SOMETHING ELSE
   }
}

 

 

Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: Dialog API doesn't return value on DevAlpha A

I'm not sure why it's not returning the way the docs say, I'll look in to that.

 

But for now what you could do is just compare the index.response, to whatever button you like.. something like this...

 

if (index.result == "yes") {
   // do this
} else {
      // do that
}

 

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Developer
barlowdot1
Posts: 35
Registered: ‎02-06-2011
My Device: bold 9900
My Carrier: Vodacom

Re: Dialog API doesn't return value on DevAlpha A

Hey Chadtatro

 

Your last suggested solution (index.result) returns "undefined".

Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: Dialog API doesn't return value on DevAlpha A

I would try to debug it in the console.log then in this case.  See what "index" contains.

 

console.log(index); should do it.

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Developer
barlowdot1
Posts: 35
Registered: ‎02-06-2011
My Device: bold 9900
My Carrier: Vodacom

Re: Dialog API doesn't return value on DevAlpha A

Chadtaro

 

console.log(index) on Ripple/Chrome returns 0 and 1 on button pressed, However console.log(index) returns "No" and "Yes" from Dev Alpha via web inspector. 

 

I've modified my code as follow but still not getting the desired results on Dev Alpha.

if(index=="Yes"){
   //do something
}else{
   //do something else
}

 

Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: Dialog API doesn't return value on DevAlpha A

Chad's solution is the correct one, but he mispelled the code example.

It's index.return and not index.result.

fix that and it should work fine.

Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.