呼叫弹出按钮:
<div class="buttons">
<button type="button" data-for="cleaning-info" class="actionButton dialog-link">
Cleaning</button>
<button type="button" data-for="notes-info" class="actionButton dialog-link">
Notes</button>
</div>
Jquery UI 弹出窗口 1:
<div class="pet-profile dialog" id="cleaning-info" data-width="600" data-title="Pet Sitter Cleaning">
<% using (Html.BeginAbsoluteRouteForm("PetDetail", new { controller = "PetSitters", action = "SavePetSitterCleaningRecords", ownerKey = Model.Owner.Key, petKey = Model.Key }, FormMethod.Post, new { id = "addPetSitterCleaning" }))
{ %>
<%: Html.CompleteEditorFor(m => m.PetSitterCleaningRecord.WhereIsTheScoop)%>
<button type="submit" class="actionButton default">
Save</button>
<%} %>
</div>
Jquery UI 弹出窗口 2:
<div class="pet-profile dialog" id="notes-info" data-width="550" data-title="Pet Sitter Notes">
<% using (Html.BeginAbsoluteRouteForm("PetDetail", new { controller = "PetSitters", action = "SavePetSitterNotes", ownerKey = Model.Owner.Key, petKey = Model.Key }, FormMethod.Post, new { id = "addPetSitterNotes" }))
{ %>
<%: Html.CompleteEditorFor(m => m.PetSitterNote.Note1)%>
<button type="submit" class="actionButton default">
Save</button>
<%} %>
</div>
弹出窗口 1 和 2 的 Jquery 代码:
//popup 1
var dialogPetSitterCleaningInfo = $('#cleaning-info');
//save button
var petSitterCleaningSave = dialogPetSitterCleaningInfo.find($('.actionButton.default[type=submit]'));
var petSitterCleaningForm = dialogPetSitterCleaningInfo.find($("#addPetSitterCleaning"));
//disable
petSitterCleaningForm.submit(function () {
petSitterCleaningSave.attr('disabled', 'disabled');
petSitterCleaningSave.addClass('disabled');
});
//popup 2
var dialogPetSitterNotesInfo = $('#notes-info');
//save button
var petSitterNotesSave = dialogPetSitterNotesInfo.find($('.actionButton.default[type=submit]'));
var petSitterNotesForm = dialogPetSitterNotesInfo.find($("#addPetSitterNotes"));
//disable
petSitterNotesForm.submit(function () {
petSitterNotesSave.attr('disabled', 'disabled');
petSitterNotesSave.addClass('disabled');
});
以上所有代码都在同一个文件中CustomersHomeModal.aspx
用户界面如下:
我的问题:
按下相关弹出窗口的按钮时,如何仅调用相关的弹出 jquery 代码。目前首先运行自己加载所有jquery代码(与两个弹出窗口相关)。我需要避免这种情况。
如何做到这一点(简单的例子非常感谢)?