使用json 和jQuery制作级联dropdownlist

简介:

联动式的下拉选择是一个很普遍的需求,在ASP.NET MVC中可以使用Json和jQuery来实现,更简单的是使用jQuery的级联插件CascadingDropDown ,具体参见文章http://weblogs.asp.net/rajbk/archive/2010/05/20/cascadingdropdown-jquery-plugin-for-asp-net-mvc.aspx

1: $(targetID).CascadingDropDown(sourceID, actionPath, settings) 
   2:  
   3: •targetID 
   4: The ID of the select list that will auto populate.  
   5:  
   6: •sourceID 
   7: The ID of the select list, which, on change, causes the targetID to auto populate. 
   8:  
   9: •actionPath 
  10: The url to post to 
  11: Options
  12:  
  13: •promptText 
 14: Text for the first item in the select list 
  15: Default : -- Select -- 
  16:  
  17: •loadingText 
  18: Optional text to display in the select list while it is being loaded. 
  19: Default : Loading.. 
  20:  
  21: •errorText 
  22: Optional text to display if an error occurs while populating the list 
  23: Default: Error loading data. 
  24:  
  25: •postData 
  26: Data you want posted to the url in place of the default 
  27: Example : 
  28: postData: function () { 
  29:     return { prefix: $('#txtPrefix').val(), customerID: $('#customerID').val() }; 
  30: } 
  31: will cause prefix=foo&customerID=bar to be sent as the POST body. 
  32: Default: A text string obtained by calling serialize on the sourceID 
  33:  
  34: •onLoading (event) 
  35: Raised before the list is populated. 
  36:  
  37: •onLoaded (event) 
  38: Raised after the list is populated, The code below shows how to “animate” the  select list after load.

本文来自云栖社区合作伙伴“doNET跨平台”,了解相关信息可以关注“opendotnet”微信公众号

目录
相关文章
|
5月前
|
JSON 前端开发 Java
利用Spring Boot处理JSON数据实战(包括jQuery,html,ajax)附源码 超详细
利用Spring Boot处理JSON数据实战(包括jQuery,html,ajax)附源码 超详细
62 0
|
6月前
|
JSON JavaScript 数据格式
jQuery将json性别数据int类型进行格式化渲染
jQuery将json性别数据int类型进行格式化渲染
27 0
|
6月前
|
JSON 数据格式
jQuery+ajax解析json数据渲染
jQuery+ajax解析json数据渲染
31 0
|
7月前
|
XML JSON JavaScript
基于jquery+html开发的json格式校验工具
JSON是一种轻量级的数据交换格式。 易于人阅读和编写。同时也易于机器解析和生成。
36 0
|
11月前
|
XML 存储 JSON
【jquery】前端数据格式:json、xml对比
【jquery】前端数据格式:json、xml对比
95 0
|
前端开发 JavaScript
前端学习案例6-Json互转的方式和jquery深拷贝
前端学习案例6-Json互转的方式和jquery深拷贝
57 0
前端学习案例6-Json互转的方式和jquery深拷贝
|
前端开发 JavaScript
前端学习案例6-Json互转的方式和jquery深拷贝
前端学习案例6-Json互转的方式和jquery深拷贝
58 0
前端学习案例6-Json互转的方式和jquery深拷贝
|
JSON 前端开发 JavaScript
jquery ajax 和servlet json 结合的简单小例子
jquery ajax 和servlet json 结合的简单小例子
110 0
|
JSON JavaScript 数据格式
jquery请求json数据失败但是不报错
jquery请求json数据失败但是不报错
139 0
jquery请求json数据失败但是不报错
|
前端开发 Java
制作温馨浪漫爱心表白动画特效HTML5+jQuery【附源码】
制作温馨浪漫爱心表白动画特效HTML5+jQuery【附源码】,祝大家情人节快乐。
131 0