2012-07-24 42 views
0

我使用自动从该网站提示的jQuery插件:多标签建议的jQuery插件

http://code.drewwilson.com/entry/autosuggest-jquery-plugin

制作标签多个像在该网站给出。

但我的问题是... 从autosuggest中选择时,它显示在我的输入框中,但我不想再次显示选定的autosuggest,就像链接中给出的示例一样....但我我不能做这种事情......

请帮我......被我用来 代码如下:

<link rel="stylesheet" type="text/css" href="view/stylesheet/autoSuggest.css"> 

<script type="text/javascript" src="view/javascript/jquery/jquery.autoSuggest.js"></script> 

<script type="text/javascript"><!-- 

$("#product_tag1").autoSuggest("http://test.com/ajax", {minChars: 2, matchCase: true,selectedItemProp: "tag", searchObjProps: "tag"}); 

//--></script> 

阿贾克斯文件中像

<? 

$input = $_GET["q"]; 

$data = array(); 


$query = mysql_query("SELECT * FROM my_table WHERE my_field LIKE '%$input%'"); 

while ($row = mysql_fetch_assoc($query)) { 

$json = array(); 

$json['tag_id'] = $row['id']; 

$json['tag'] = $row['tag']; 



$data[] = $json; 

} 

header("Content-type: application/json"); 

echo json_encode($data); 

?> 
+0

我得到了解决方案,它工作正常... – 2012-07-26 06:00:16

回答

1

我可以建议使用Select 2插件吗?它正在积极发展,并有恕我直言更好的特点;例如当控件具有焦点并且不允许多次选择相同标签时显示可用标签的列表。

这听起来像它会做你想要的,但请参阅Tagging Example所有选项的描述。根据您的示例代码,我认为切换插件并不困难。

+0

这是一个强大的插件就在那里,谢谢! – Alex 2012-07-24 09:07:39

0

通过在JavaScript的文档准备功能使用以下代码

$(文件)。就绪(函数() { VAR数据= NULL; VAR数据=; (“#tag”)。autoSuggest(“config-> item('admin_folder')。'/ products/autosuggest');?>”,{minChars:2,matchCase:true,selectedItemProp:“name”, searchObjProps:“name”,selectedValuesPro p:“value”,preFill:data}); });