加载仅与特定弹出窗口相关的jquery

时间:2013-02-14 13:31:54

标签: jquery asp.net-mvc-2 jquery-ui-dialog

通话弹出按钮:

<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&amp;的Jquery代码2:

//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

用户界面如下:

enter image description here

我的问题:

按下相关的弹出按钮时,如何只调用相关的弹出式jquery代码。 目前首先运行自己加载所有jquery代码(与两个弹出窗口相关)。我需要避免这种情况。

如何做到这一点(非常感谢简单的例子)?

0 个答案:

没有答案