标签:div sea hold exp arch script ima url success
var getIDNameList = function (list, selected, text, btn, actionUrl, defaultKey, deleteKey, keyName, valueName, callBackFuc) { btn.bind("click keyup", { sText: text }, function (e) { $.ajax({ url: actionUrl, contentType: "application/json", type: "GET", success: $.proxy(function (data) { var comparStr = this.val(); for (var i = 0; i < data.length; i++) { if (data[i][valueNameStr].indexOf(comparStr) == -1) continue; } }, e.data.sText) }); }); } //调用 var i=1; getIDNameList( $(‘#List‘ + i), $(‘#S‘ + i), $(‘#searchText‘ + i), $(‘#searchBtn‘ + i), "../scripts/A04/A0410.json", null, null, "Key", "Value", function (obj) { }); //HTML <div class="btn-group"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <span data-bind="attr:{id:‘S‘+$index()}">请选择</span><span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" data-bind="attr:{id:‘List‘+$index()}" ></ul> <div class="input-group"> <input type="text" class="form-control" data-bind="attr:{id:‘searchText‘+$index()}" placeholder="专业类别名称"> <span class="input-group-btn"> <button class="btn btn-primary" id="c2-searchBtn" data-bind="attr:{id:‘searchBtn‘+$index()}" type="button"> 搜索 </button> </span> </div> </div> // A0410.json [{ "Key": "1", "Value": "哲学" }, { "Key": "101", "Value": "哲学类" }, { "Key": "10101", "Value": "哲学" }, { "Key": "10102", "Value": "逻辑学" }]
一个比较变态的js传值,Query的bind、ajax闭包、上下文传值
标签:div sea hold exp arch script ima url success
原文地址:http://www.cnblogs.com/badnewfish/p/6954243.html