まだDOMにない要素にカスケード関数をバインドするにはどうすればよいですか:
(function ($) {
$.fn.cascade = function (options) {
var defaults = {};
var opts = $.extend(defaults, options);
// REST OF THE CODE NOT IMPORTANT FOR THE QUESTION //
};
})(jQuery);
読み込まれる Partialview には次のものが含まれます。
@Html.DisplayNameFor(m => m.PTDistrict_Id)
@Html.DropDownListFor(m => m.PTDistrict_Id, Model.PTDistrictList, HeelpResources.PTDistrictViewDropDownListFirstRecord, new { id = "districtDropdown" })
@Html.ValidationMessageFor(m => m.PTDistrict_Id)
私はこれを試しましたが、運がありません:
$(document).on("change", "#districtDropdown", function () {
$.cascade({
url: "/Address/ListCouncilByDistrict",
paramName: "districtId",
firstOption: 'Selecione o Concelho...',
childSelect: $("#councilDropdown")
});
});
何か案は?ありがとう。