select 级联回填事件触发的问题
现在遇到的问题我用下面的图说明
图一
图二
上图中的父级型号中是级联的下拉框,给定品牌型号回填到下拉框中就出现如上问题(图一所示)没有激活2级下拉框,但是手工选择的话可以弹出2级下拉框
现贴一下代码:
code1:回填数据
viewentity.prototype.getBrand = function () {
var guid = UrlParm.parm("id");
$.ajax({
contentType: 'text/json',
url: PageUrl.local + "WebServices/CommonService.svc/GetBrandModels_byBrandModelID",
type: 'post',
data: '{"guid":"' + guid+ '"}',
async: false,
success: function (result) {
if (result != null) {
debugger;
result = result.d;
for (var i = 0; i < result.length; i++) {
$("#ddl_Brand").val(result[i].value.split(";")[0]);
$("#txt_marker").val(result[i].value.split(";")[1]);
if (result[i].key.split(";")[2].indexOf("@") < 0) {
setTimeout("$("#ddl_Parentmarker option[value!='']").remove()",600);
} else {
var parentIDs = result[i].key.split(";")[2].split("@");
//35720130703473956176
setTimeout("$("#ddl_Parentmarker option[value='" + parentIDs[parentIDs.length - 2] + "']").attr('selected', true)", 600);
$("#CasCategory1 select").each(function (n) {
for (var j = parentIDs.length-1; j >= 0; j--) {
$(this).val(parentIDs[j - 1]);
break;
}
if ($("#CasCategory1 select").length - 1 == n) {
$(this).remove();
}
});
}
}
}
}
});
};
<th>父级型号</th>
<td class="fordata">
<div class="Unlimited_Cascade">
<span class="Control_Parent" id="CasCategory">
<select id="ddl_Parentmarker" class="text-input" data-bind="foreach: models">
<option data-bind="text: catename, attr: { value: cateid }"></option>
</select>
<input type="hidden" id="hfCategory" />
</span>
<span id="CasCategory1"></span>
</div>
function loadjs() {
LoadScript(myloaddata.js_PageUrl + "Javascript/Jquery.Plugins/jquery-1.4.1.js", function () {
$.Expand.cachedScript(PageUrl.js + "Javascript/Jquery.Plugins/knockout.js").done(function () {
jQuery.Expand.Script(PageUrl.js + "Javascript/User.Customize/Unlimited.Cascade.js", function () {
myloaddata.myview = new viewentity();
ko.applyBindings(myloaddata.myview);
myloaddata.um = eval('(' + myloaddata.result.um + ')');
});
});
myapply._islogin = -9;
});
}
viewentity.prototype.load = function () {
self.models = ko.observableArray([]);
self.iscurrent = ko.computed(function () { return "current" }, self);
viewentity.prototype.initSearchArea();
if (UrlParm.parm("id") != undefined) {
setTimeout("viewentity.prototype.getBrand()", 300);
self.loadtitle = ko.observable('修 改');
} else {
self.loadtitle = ko.observable('添 加');
}
var obj = {
functionRedirect: [PageUrl.local + 'WebServices/CommonService.svc/GetBrandModel', PageUrl.local + 'WebServices/CommonService.svc/GetBrandModel_Parent'],
Cs: 'ddl_Parentmarker',
HfID: 'hfCategory',
ResultID: 'CasCategory1'
};
self.c3 = new Cascade(obj);
self.c3.init();
}