Re: [問題] jquery的cascade選單應用
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 5 之 5 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章