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
SumiGhosh
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone
Accepted Solution

input prompt not working in BB10

Hi all,

Found that input prompt not woking in BB10, did any one come across the same.......

 

var setLocation=prompt("Please enter a location","");
alert("setLocation"+setLocation);

 

Thanks in advance..... :smileyhappy:

Please use plain text.
BlackBerry Development Advisor
bryanhiggins
Posts: 190
Registered: ‎12-18-2012
My Device: Z10, Q10, Q5, Z30, Z3
My Carrier: Bell

Re: input prompt not working in BB10

Hi,

 

This does work for me. You may want to take a look at standardAskAsync which gives you more control over the dialog, such as changing the title.

 

https://developer.blackberry.com/html5/apis/blackberry.ui.dialog.html#.standardAskAsync

 

Thanks,

Bryan

Bryan Higgins
BlackBerry WebWorks
@bryanhiggins
Please use plain text.
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: input prompt not working in BB10

Not working for me using Dev Alpha C.

I copy and paste his code into the console and I always get back null. Having the same problem in my app.
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Please use plain text.
BlackBerry Development Advisor (Retired)
mimendoza
Posts: 64
Registered: ‎06-04-2012
My Device: Blackberry Z10
My Carrier: Bell

Re: input prompt not working in BB10

[ Edited ]

The prompt() method is working in the simulator, but there is an issue when testing on the dev C device.

 

Rather than using generic dialogs, I would suggest to use the BlackBerry Dialog instead. There is a KB Article showing the different types of dialogs you can use, the API doc is here.

 

The code below has been tested to work on the device and on the simulator.

 

<script type="text/javascript">

function dialogCallBack(selection){
  alert(selection.return); // the button that the user clicked
  alert(selection.promptText); // the text that the user entered
}

function standardDialog() {
  try {
    blackberry.ui.dialog.standardAskAsync("Your name?", blackberry.ui.dialog.D_PROMPT, dialogCallBack, {title : "Custom Title"});
  }catch (e) {
    alert("Exception in standardDialog: " + e);
  }
}

</script>
----------------------------------------------------------------------------------
- Did this post help solve the issue? Click on "Accept as Solution"
- Was the content of this post helpful? Please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Please use plain text.
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: input prompt not working in BB10

[ Edited ]

@mimendoza sorry I thought your latest responce was working when I tweeted but I was wrong(or more likely I'm implementing it wrong). 

 

I'm running the following on DevAlpha C and BB10 release phone, via JS console.

 

function dialogCallBack(selection){
alert(selection.return);
}

var setLocation=blackberry.ui.dialog.standardAskAsync("Enter your location.", blackberry.ui.dialog.D_PROMPT, dialogCallBack, {title : "Location"});
alert("setLocation"+setLocation);

 

I get Location of undefined.

 

What am I doing wrong?

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Please use plain text.
BlackBerry Development Advisor (Retired)
mimendoza
Posts: 64
Registered: ‎06-04-2012
My Device: Blackberry Z10
My Carrier: Bell

Re: input prompt not working in BB10

You shouldn't store the result of this function in a variable, rather, you can use the dialogCallBack() function, this is where you can get the value of the user input text, using the promptText property and can set it to a variable.

 

function dialogCallBack(selection){
  alert(selection.return); // the button that the user clicked
  alert(selection.promptText); // the text that the user entered
}

 

----------------------------------------------------------------------------------
- Did this post help solve the issue? Click on "Accept as Solution"
- Was the content of this post helpful? Please give it a "Thumbs Up"

developer.blackberry.com
@BlackBerryDev
Please use plain text.
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Re: input prompt not working in BB10

Thanks @mimedoza

And for anyone else reading if like me you are building cross platform you can always do the following

put your BlackBerry specific code in an if statement like this...

if(blackberry){
... code here
}else{
... standard prompt here
}
_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Please use plain text.
Developer
denniskis
Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO

Re: input prompt not working in BB10

I'm wondering why the dialog prompt has no default text parameter in the settings object? This is very sad. If you want the user to provide a rename function throught the bb dialog it's not possible to do via webworks. Even prompt("text","default text") is not working :smileysad:

Please use plain text.