开发者

Page losing focus

Hi I have a small javascript function I am calling after updatin开发者_StackOverflow中文版g a grid using ajax. I ran into a problem with losing page focus after refreshing the grid. I am trying to use the following code to get the active element, refresh the grid, then reset focus to its previous state.

var selectedTextArea = document.activeElement;
grid1.refresh();
document.getElementById(selectedTextArea.id).focus();

This seems to work except that the focus is being set before the refresh has finished executing so the page still loses focus. Any ideas on why this is happeneing and how I can fix the problem?


It sounds like your grid refresh function is performing an asyc operation. You will need to capture your grid finishing its refresh, and performing your focus call there.

It is a little difficult to answer in more detail without knowing what framework you are using to build your grid or what refreshing the grid entails. More details will likely give more complete results.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜