var searchACProduct = new SearchAC
YUI({ combine : true, comboBase : '', modules : { 'ntes-placeholder' : { fullpath : '', requires : [ 'classnamemanager', 'node', 'plugin' ] } } }).use( 'ntes-placeholder', 'autocomplete', //'autocomplete-highlighters', 'io-base', 'json-parse', function(Y) { var searchBriefBrand = Y.one('#searchbriefbrand'), searchBriefBrandID = Y .one('#searchbriefbrandid'), searchBriefProduct = Y.one('#searchbriefproduct'), searchBriefProductID = Y .one('#searchbriefproductid'); searchBriefBrand.plug(Y.Plugin.Placeholder); searchBriefProduct.plug(Y.Plugin.Placeholder); var SearchAC = function(srcNode, srcNodeID, data) { srcNode.plug(Y.Plugin.AutoComplete, { zIndex : 100, maxResults : 10, //resultHighlighter: 'phraseMatch', resultFilters : function(query, results) { return Y.Array.filter(results, function(result) { return result.raw.filter.toLowerCase().indexOf(query.toLowerCase()) !== -1 }); }, resultTextLocator: 'text', source : data }); srcNode.ac.after('select', function(e) { var result = e.result; srcNodeID.set('value', result.raw.id); }); srcNode.ac.after('valueChange', function(e) { srcNodeID.set('value', ''); }); } //品牌 var _brandFailure = function(ioId, o) { }, _brandSuccess = function(ioId, o) { var data = Y.JSON.parse(o.responseText); var searchACBrand = new SearchAC(searchBriefBrand, searchBriefBrandID, data); }; searchBriefBrand.once('focus', function() { Y.io('', { method : 'GET', on : { success : _brandSuccess, failure : _brandFailure } }) }); //產品 var brandidtmp = '', _productFailure = function(ioId, o) { }, _productSuccess = function(ioId, o) { var data = Y.JSON.parse(o.responseText); var searchACProduct = new SearchAC(searchBriefProduct, searchBriefProductID, data); }; searchBriefProduct.on('focus', function() { var brandid = searchBriefBrandID.get('value'); if (brandid != '' && brandid != brandidtmp) { brandidtmp = brandid; Y.io('' + brandid + '.json', { method : 'GET', on : { success : _productSuccess, failure : _productFailure } })
頁:
[1]