var WEBDOMAIN = '<{$web_cfg.domain}>'; var catNamesJson = '<{$catNamesJson}>'; KISSY.use('node, io, combobox, json', function(S, Node, IO, ComboBox, JSON) { var $ = KISSY.all, DOM = KISSY.DOM; var catNames = JSON.parse(catNamesJson); var basicComboBox = new ComboBox({ width:100, srcNode:S.one("#combobox"), // 初始就聚焦 focused:true, hasTrigger:false, maxItemCount:10, dataSource:new ComboBox.LocalDataSource({ data:catNames }) }); basicComboBox.render(); basicComboBox.on("click", function (e) { var item = e.target; var cat = item.get("value"); $("#proList").html('<li class="list-group-item">加载中...</li>'); getProducts(cat); $(".ks-menuitem").hide(); }); function getProducts(cat) { new IO({ type: 'post' , url: WEBDOMAIN + '/?c=Admin_EastBeauty_Search&a=search' , data: {cat:cat} , success: function(data) { $("#proList").empty(); if (data.ok) { for(n in data.msg) { str = '<li class="list-group-item">(' + data.msg[n].productid + ') ' + data.msg[n].name + ' ' + data.msg[n].avg_score + '</li>'; $("#proList").append(str); } } else { alert('操作失败,原因:' + data.msg); } } , error: function(NULL, textStatus) { alert('请求失败,原因:' + textStatus); } , dataType: 'json' }); } });
转载于:https://www.cnblogs.com/bandbandme/p/11193254.html
相关资源:Text文本框添加模糊搜索功能