简体   繁体   中英

dont work event on script for element on partial view

i have index.cshtml view with script

$("#SearchingManagerId2").on("change", function () {
                var valueForSearch = $(this).val();
                $.ajax({
                    url: '@Url.Action("FillQualificationTable")',
                    dataType: 'html',
                    async: false,
                    data: { year: currentYear, ManagerId: valueForSearch },
                    success: function (data) {
                        $('#tableContainerQualification').html(data);
                    },
                });
            });

also i have partial Qualification on it. its contain two actions that include 2 more partials

<body>
    @Html.Action("SetSearchFilterQualification")//This one return filter SearchingManagerId2
    @Html.Action("FillQualificationTable")//This one return table thats must be refresh 
</body>

Why my script dont working on partial (Qualification) And where i must deploy it

I think that your problem is in the rendering order, if you attach the event (SetSearchFilterQualification) after the table creation (fillQualificationTable) the script doesn't find the DOM object because is not rendered yet. Try changing the order of the actions.

<body>
    @Html.Action("FillQualificationTable")//This one return table thats must be refresh 
    @Html.Action("SetSearchFilterQualification")//This one return filter SearchingManagerId2
</body>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM