一個比較變態的js傳值,Query的bind、ajax閉包、上下文傳值

來源:互聯網
上載者:User

標籤: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閉包、上下文傳值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.