开发者

Programmatically change focus in blackberry webworks application

开发者 https://www.devze.com 2023-03-22 00:27 出处:网络
I am working on developing a WebWorks app that uses JQuery\'s \"show\" and \"hide\" methods to dynamically change page contents.

I am working on developing a WebWorks app that uses JQuery's "show" and "hide" methods to dynamically change page contents.

The application initially loads a page with a few text inputs as well as a JQuery styled hyperlink button. Focus on the start page is defined with the x-blackberry-initialFocus attribute.

When one of the hyperlink buttons is selected JQuery hides the displayed text inputs and buttons, and shows a different set of text inputs and hyperlink buttons. At this point, focus navigation breaks and it appears that no element has focus.

I have tried adding permissions to use blackberry.focus to my config.xml and executing " blackberry.focus.setFocus('my_text_input_id'), " but that did not have any effect.

I guaranteed that the call to setFocus was executed after the desired HTML element was added to the DOM by putting the call to setFocus in the JQuery show method's callback function. I also used JQuery to select the desired text 开发者_StackOverflow中文版input before calling setFocus to ensure that the element was existant.

Additionally, I called blackberry.focus.getFocus() before and after calling setFocus() , but the getFocus() method returned an empty string on each call.

Does anyone know why I can't seem to regain focus?


I had exactly the same problem.

I found that blackberry.focus.setFocus("element"); had not effect, but If I click in the element that make the show/hide effect once more, code work fine.

Then the solution is use setTimeout:

setTimeout(function(){
   blackberry.focus.setFocus("show_menu");
},100);

It works really good.

I hope this helps you to solve your problem

0

精彩评论

暂无评论...
验证码 换一张
取 消