查找当前关注的组件ID以显示在线/上下文帮助系统 [英] Find Current focused component ID to Show Online / Context HelpSystem

查看:330
本文介绍了查找当前关注的组件ID以显示在线/上下文帮助系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的primefaces页面实现在线(上下文)帮助。我正在考虑组件的id作为context_id和每个上下文Id,帮助文本在数据库中可用。当用户需要组件的帮助时,焦点应该在组件中,并且用户必须

方法1.按F1键 -
方法2将鼠标移动到一个(帮助)图标上

然后根据当前聚焦的组件ID从数据库中获取上下文ID的文本将被挑选并显示在屏幕上。



我们如何在不使用javascript / jQuery的情况下获得当前集中的组件id?

解决方案<以下jQuery是我的问题的解决方案。这更新了一个隐藏的inputText访问每个组件(但跳过帮助按钮本身)。点击帮助按钮,从隐藏的inputText中获取活动组件的id,并从资源包中为该ID提取帮助(我的资源包是从具有每个组件ID的帮助文本的数据库中创建的)

  $(document).ready(function(){
$(body)。delegate(:input,focus点击,函数(){
if($(this).attr('id')!='hiddenInput'& amp; amp; $(this).attr('id')!= 'helpButton'){
$('#hiddenInput')。val($(this).attr('id'));
}
});
}) ;


I want to implement online (context) help for my primefaces pages. I am considering the id of a component as the context_id and for each context Id, help text is available in the database. When user wants help on a component, focus should be there in the component and user has to

Method 1. Press F1-key
Method 2. Move mouse on to a (help) icon

Then help text from the database for the context id as per the currently focused component id will be picked and shown on screen.

How can we get the currently focused component id without using javascript / jQuery ?

解决方案

Following jQuery is the solution for my problem. This Updates a hidden inputText on visiting each component (but skips this on click of help button itself). On click of help button, the id of the active component is obtained from the hidden inputText and help is extracted for that ID from resource bundle (My resource bundle is created from database having the help text for each component ID)

$(document).ready(function(){    
    $("body").delegate(":input", "focus click", function(){
        if($(this).attr('id') != 'hiddenInput' &amp;&amp; $(this).attr('id') != 'helpButton'){
                $('#hiddenInput').val($(this).attr('id'));
         } 
    }); 
});

这篇关于查找当前关注的组件ID以显示在线/上下文帮助系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆