作者appleboy46 (小恶魔)
看板Ajax
标题Re: [问题] jquery的cascade选单应用
时间Sun Dec 21 19:34:38 2008
※ 引述《appleboy46 (小恶魔)》之铭言:
: $(document).ready(function()
: {
: $("#user_department").cascade("#user_college", {
: ajax: {
: type: 'GET',
: url: 'ajax.php',
: data: { action: 'show', val: $('#user_college').val() }
: },
: template: commonTemplate,
: match: commonMatch
: });
: });
: 这样就可以了,请问 cascade 只能吃 val 这个变数?
: 换成其他的就不行了阿? Orz 竟然会出现这种奇怪的情形
恩 刚刚去看了一下 jquery.cascade.ext.js souce code
$.ui.cascade.ext.ajax = function(opt) {
var ajax = opt.ajax;//ajax options hash...not just the url
return { getList: function(parent) {
var _ajax = {};
var $this = $(this);//child element
var defaultAjaxOptions = {
type: "GET",
dataType: "json",
success: function(json) { $this.trigger("updateList",
[json]); },
data: $.extend(_ajax.data,ajax.data,{
val:
opt.getParentValue(parent) })
};
//overwrite opt.ajax with required props
(json,successcallback,data)
//this lets us still pass in handling the other ajax callbacks
and options
$.extend(_ajax,ajax,defaultAjaxOptions);
$.ajax(_ajax);
} };
};
已经用了 val 这个变数了,所以难怪用其他变数去接,会没作用,导致 ajax 失效
http://blog.wu-boy.com/2008/12/19/637/
--
Appleboy Blog:
http://blog.Wu-Boy.com
Appleboy Life:
http://life.wu-boy.com
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.123.107.20