本文介绍了AutoCompleter正常运行,但是在处理其他事件时未显示默认文本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Struts 2中有一个自动完成标记.

I have an autocompleter tag in Struts 2.

将标签放在自动完成器上时,我需要执行某些操作.

I have certain operations to be done when the tag is placed on the autocompleter....

重点是,当我单击自动完成器文本框时,文本Select or Type tag ends with ;将被删除.

On focus, when I click the autocompleter textbox, the text Select or Type tag ends with ; will be removed.

如果我处理其他事件,则该文本应重新出现.

If I process some other event, the text should reappear.

如何实现此功能?

<sj:autocompleter  
           cssStyle="width:200px;" 
               href="%{#autoCompleteTagUrl}" 
     onSelectTopics="tagsAllSelectTopics" 
   onCompleteTopics="tagsAllCompleteTopics"
                 id="tags_all" 
               name="tags_all" 
           cssClass="inputText tags_all tag-textbox docTxt" 
            tooltip="true" 
              value="Select or Type tag ends with ;" 
            onfocus="if(this.value=='Select or Type tag ends with;'){this.value='';}" 
        loadingText="Loading...." 
/>

推荐答案

自动完成程序没有占位符属性,因为自动完成程序通常用于用户输入所提供列表内的文本,并且该列表在用户使用时显示类型或是否单击了下拉箭头(如果启用了箭头).

Autocompleter does not have a placeholder attribute because autocompleter is usually meant for users to input text that fall within a provided list and this list is shown as and when the user types or if the drop down arrow is clicked(if arrow is enabled).

此处是自动填充程序支持的属性列表.

Here is a list of attributes supported by autocompleter.

但是如果要那样做,那么如果value =="

But if want to do it like that then use the onfocusout event to put the text back if value==""

<sj:autocompleter  
       cssStyle="width:200px;" 
       href="%{#autoCompleteTagUrl}" 
       onSelectTopics="tagsAllSelectTopics" 
       onCompleteTopics="tagsAllCompleteTopics"
       id="tags_all" 
       name="tags_all" 
       cssClass="inputText tags_all tag-textbox docTxt" 
       tooltip="true" 
       value="Select or Type tag ends with ;" 
       onfocus="if(this.value=='Select or Type tag ends with;'){this.value='';}" 
       loadingText="Loading...." 
       onfocusout="if(this.value==""){this.value='Select or Type tag ends with';}
  />

这篇关于AutoCompleter正常运行,但是在处理其他事件时未显示默认文本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 11:02