嗨,有人可以幫助我與這個jQuery?我有:jquery如何調用文檔準備好的功能
$(document).ready(function() {
window.refresh = function() { setorganisationddl; }
var setorganisationddl = function() {
if ($("#Invoice_AreaId option:selected").val() == "") {
$("#Invoice_OrganisationId > option").remove();
$("#Invoice_OrganisationId").append($("<option value=''>-- Select --</option>"));
$("#Invoice_OrganisationId").attr("disabled", "disabled");
}
else {
$.get('/Invoice/GetOrganisationSelectList/' + $("#Invoice_AreaId option:selected").val(), function (response) {
$("#Invoice_OrganisationId").removeAttr("disabled");
var organisations = $.parseJSON(response);
var ddlOrganisations = $("#Invoice_OrganisationId");
$("#Invoice_OrganisationId > option").remove();
for (i = 0; i < organisations.length; i++) {
if (organisations[i].Value == $("#Invoice_OrganisationId option:selected").val()) {
ddlOrganisations.append($("<option selected='selected' />").val(organisations[i].Value).text(organisations[i].Text));
}
else {
ddlOrganisations.append($("<option />").val(organisations[i].Value).text(organisations[i].Text));
}
}
});
}
}
$("#Invoice_AreaId").change(setorganisationddl);
});
所以我setorganisationddl正時與DDL ID Invoice_AreaId改變調用。大。不過,我也希望它在頁面加載時調用。
正如你可以看到我嘗試:
window.refresh = function() { setorganisationddl; }
不工作。