av手机免费在线观看,国产女人在线视频,国产xxxx免费,捆绑调教一二三区,97影院最新理论片,色之久久综合,国产精品日韩欧美一区二区三区

java語言

BootStrap select2 如何實現(xiàn)動態(tài)改變值

時間:2025-02-02 03:47:10 java語言 我要投稿
  • 相關(guān)推薦

BootStrap select2 如何實現(xiàn)動態(tài)改變值

  導(dǎo)語:BootStrap select2 如何實現(xiàn)動態(tài)改變值呢?下面小編給大家提供了代碼實現(xiàn)教程,大家可以參考閱讀,更多詳情請關(guān)注應(yīng)屆畢業(yè)生考試網(wǎng)。

  1,selec2動態(tài)賦值

  var temp=JSON.stringify({ id: "1|所有停車場", name: "所有停車場" });

  $("#e_pid").attr("value", tempP);

  $("#e_pid").select2({

  placeholder: "查找停車場名稱(多選)",

  language: "zh-CN",

  minimumInputLength: 1,

  allowClear: true,

  multiple: true,

  ajax: {

  // instead of writing the function to execute the request we use Select2's convenient helper

  url: "/manage/park/index/json/index",

  dataType: 'json',

  data: function (term, page) {

  return {

  parkName: term,// search term

  powerpid: "1"

  };

  },

  results: function (data, page) { // parse the results into the format expected by Select2.

  // since we are using custom formatting functions we do not need to alter remote JSON data

  for (var i = 0; i < data.length; i++) {

  data[i].id = data[i].id+"|"+data[i].name;

  };

  data.push({ id: "577cb125f8d2c404572413d1|無", name: "無" });

  return {

  results: data

  };

  }

  },

  initSelection: function (element, callback) {

  //賦初始值

  // the input tag has a value attribute preloaded that points to a preselected movie's id

  // this function resolves that id attribute to an object that select2 can render

  // using its formatResult renderer - that way the movie name is shown preselected

  var data = [];

  var value = ""

  var str = $(element).val().split('^');

  for (var i = 0; i < str.length; i++) {

  var temp = JSON.parse(str[i]);

  value += temp.id + ",";

  data.push(temp);

  }

  ;

  value = value.substring(0, value.length - 1);

  $(element).val(value);

  callback(data);

  },

  formatSelection: function (item) {

  return item.name;//注意此處的name,要和ajax返回數(shù)組的鍵值一樣

  }, // 選擇結(jié)果中的顯示

  formatResult: function (item) {

  return item.name;//注意此處的name

  },// 搜索列表中的顯示

  dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller

  escapeMarkup: function (m) {

  return m;

  }

  });

  2,動態(tài)改變值

  $("#e_pid").attr("value", temp);

【BootStrap select2 如何實現(xiàn)動態(tài)改變值】相關(guān)文章:

如何簡單實現(xiàn)bootstrap選項卡效果09-14

Bootstrap的php制作動態(tài)分頁標(biāo)簽10-26

如何實現(xiàn)bootstrap jquery dataTable異步ajax刷新表格數(shù)據(jù)09-26

Java中如何實現(xiàn)顯示動態(tài)的時間09-28

如何運用PS實現(xiàn)人物姿態(tài)的改變08-20

關(guān)于Java動態(tài)實現(xiàn)的方法08-23

java利用反射實現(xiàn)動態(tài)代理實現(xiàn)代碼10-08

java使用動態(tài)代理來實現(xiàn)AOP05-29

如何實現(xiàn)硬盤對拷06-30