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
Regular Contributor
iruka
Posts: 79
Registered: ‎09-17-2012
My Device: Torch 9800
My Carrier: DiGi

Giving Focus to Textarea inside Top Layer Div

I'm trying to give focus to a textarea inside a div that is on top of another div. This is how it goes div#container is the bottom div whereby it will list out rows of records from database and there will be a link for users to click on ADD.

 

strBtmDiv += '<div id="container">';
strBtmDiv += '<table id="tablePending">';
strBtmDiv += '<tr>';
strBtmDiv += '<td>Detail One</td><td>Detail Two</td><td>Detail Three</td><td 
onclick="showDialog()">ADD</td>';
strBtmDiv += '</tr>';
strBtmDiv += '</table>';
$('#mainBody').html(strBtmDiv);

 When user clicks on ADD onclick will fire another function showDialog() that displays a textarea and submit button for user to submit the addedd text.

 

strDialog += '<div id="overlay">';
strDialog += '<table id="tblDialog">';
strDialog += '<tr>';
strDialog += '<td><textarea id="textRemark" cols="10" rows="5"></textarea></td><td><input type="submit" value="Submit"></td>
strDialog += '</tr>';
strDialog += '</table>';
strDialog += '</div>';
$('#container').after(strDialog);

setTimeout(function () {blackberry.focus.setFocus('textRemark'); }, 300);

 

showDialog()/div#overlay will be added after the div#container and then using css z-index so div#overlay will appear on top of div#container. I have tried to set focus to the textarea using setTimeout(function () {blackberry.focus.setFocus('textRemark'); }, 300) but it is not working. Can anyone please help?

 

Thank you.

Please use plain text.
New Contributor
ReelAlien
Posts: 8
Registered: ‎10-20-2012
My Device: Playbook
My Carrier: Rogers

Re: Giving Focus to Textarea inside Top Layer Div

Have you tried something like...

 

function getfocus()
{
document.getElementById('textRemark').focus()
}

Please use plain text.
Regular Contributor
iruka
Posts: 79
Registered: ‎09-17-2012
My Device: Torch 9800
My Carrier: DiGi

Re: Giving Focus to Textarea inside Top Layer Div

Thank you. It's working.

 

But how do I use blackberry.focus.setFocus?

Please use plain text.
New Contributor
ReelAlien
Posts: 8
Registered: ‎10-20-2012
My Device: Playbook
My Carrier: Rogers
Please use plain text.
Regular Contributor
iruka
Posts: 79
Registered: ‎09-17-2012
My Device: Torch 9800
My Carrier: DiGi

Re: Giving Focus to Textarea inside Top Layer Div

Thanks for the link but is there any examples to show how to use them?

Please use plain text.
New Contributor
ReelAlien
Posts: 8
Registered: ‎10-20-2012
My Device: Playbook
My Carrier: Rogers

Re: Giving Focus to Textarea inside Top Layer Div

Please use plain text.