Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
550 views
in Technique[技术] by (71.8m points)

jquery - How to pass dropdown selected values from Modal to Parent page using ABP?

I am trying to implement a modal in a form using ABP.io framework. The modal will popup when a button will be clicked and then will show two select options. When the values will be selected and clicked the save button, it will pass the values to the parent page. I have followed a similar way as shown in the ABP web development tutorial. (https://docs.abp.io/en/abp/latest/UI/AspNetCore/Modals#functions)

I have written the following code for Modal:

Modal.cshtml

<abp-modal-body>

        <abp-select id="staffSelection" asp-for="@Model.StaffId" asp-items="@Model.StaffLookupList" label="@L["Staffs"].Value" />

        <abp-select id="roleSelection" asp-for="@Model.RoleId" asp-items="@Model.StaffRoleLookupList" label="@L["Roles"].Value" />

    </abp-modal-body>

I am using jquery to get the selected value and pass it to the parent page.

Modal.js

    var abp = abp || {};

abp.modals.programmeCohortStffRoleCreate= function () {
    var initModal = function (publicApi, args) {
        //code to get the selected options and pass to parent page
        
    };

    return {
        initModal: initModal
    };
};

From the documentation, I could understand that I have to use the setResult() and onResult(callback) functions. But I could not figure out how to use those functions to pass the selected values from the modal to the parent page.

the Modal is called from the script of the parent page using the following code:

ParentPage.js

//Staff Selection Modal
var selectStaffModal = new abp.ModalManager({
    viewUrl: abp.appPath + "<path>/SelectStaffsModal",
    scriptUrl: "<path>/SelectStaffsModal.js",
    modalClass: "StffRoleCreate"
});

$("#NewStaffButton").click(function (e) {
    e.preventDefault();
    selectStaffModal.open();
    var staffId, staffName, roleId, roleName;
    
});

selectStaffModal.onResult(function(callback){
    console.log(callback); // not able to get the desired value
});

I could not find anyway to achieve this option. Please help me to do that.

question from:https://stackoverflow.com/questions/65908645/how-to-pass-dropdown-selected-values-from-modal-to-parent-page-using-abp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...