Pagnation没有更新目标

编程入门 行业动态 更新时间:2024-10-21 23:14:50
本文介绍了Pagnation没有更新目标 - 使用Ajax的Asp.Net Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望这是直截了当的!我有一个部分加载很好,它使用ajax应用过滤器/排序工作正常。然而,分页链接发送正确的URL,响应是所需的页面,只是它实际上没有更新/替换那里的什么。 父视图:

I hope this is straight forward! I have a partial which loads just fine, it uses ajax to apply filters / sorting which works fine. However the pagination links send the correct url, and the response is the desired page, only it doesn't actually update/replace whats there. Parent View:

@model Sakura.AspNetCore.IPagedList<YaCu_2017.Models.Review> @{ ViewBag.Title = "Review Dashboard"; @using YaCu_2017.Controllers; } <p class="green-text">@ViewBag.StatusMessage</p> <p class="red-text">@ViewBag.ErrorMessage</p> <h2>Our Product Reviews</h2> <div class="row"> <div class="col s2"> <h5>Filter by Product:</h5> <form method="get"> @{ var product = ReviewController.GetProductListIncId(); var productCount = ReviewController.GetProductCountList(); ViewBag.ProductList = product; ViewBag.ProductCount = productCount; } <select asp-items="@ViewBag.ProductList" id="searchProduct" class="dropdown-button btn"></select> <h5>Reviews per page</h5> <select asp-items="@ViewBag.ProductCount" id="perPage" class="dropdown-button btn"></select> </form> </div> </div> <p></p> <div class="reviewView" id="filter"> @await Html.PartialAsync("ShowReviewDetails", Model) </div>

子视图:

@model IPagedList<YaCu_2017.Models.Review> @using System.Globalization @using Sakura.AspNetCore @using YaCu_2017.Controllers @using YaCu_2017.Models @{ ViewData["Title"] = "Digital Jeeves - Reviews"; } <form method="post" data-ajax="true"> <div class="row"> <div id="pagerow" class="col s12 center center-align center-block"> <p>Page @(Model.TotalPage < Model.PageIndex ? 1 : Model.PageIndex) of @Model.TotalPage<pager id="pager" class="pagination" setting-link-attr-data-ajax-update="filter" setting-link-attr-data-ajax- mode="replace" setting-link-attr-data-ajax="true" /></></p> <cs-pager cs-paging-pagesize="@Model.PageSize" cs-paging-pagenumber="@Model.PageIndex" cs-paging-totalitems="@Model.TotalPage" cs-pagenumber-param="page" asp-route-perPage="@ViewData["Page"]" asp-route-searchProduct="@ViewData["Product"]" asp-controller="Review" asp-action="GetProducts" cs-ajax-target="filter"></cs-pager> </div> </div> </form> <hr /> <div id="stuff"> @foreach (var item in Model) { var stars = item.Stars.ToString(); var starurl = string.Format("images/stars/{0}_star.jpg", stars); <div class="container opaque-parent z-depth-5"> <div class="row"> <div class="col s6"><h6 style="border-bottom:thin">Title : @Html.DisplayFor(model => item.Title)</h6></div> <div class="col s3"><h6 style="border-bottom:thin">Product : @Html.DisplayFor(model => item.Product)</h6></div> <div class="col s3"><h6 style="border-bottom:thin">Rated: <img src="~/@starurl" class="responsive-img" id="@item.Id" /></h6></div> </div> <div class="row" style=""> <div class="col s12" style="border-bottom:inset"> <h6>Comment:</h6> </div> </div> <div class="row" style="border-bottom:inset"> <div class="col s6 offset-s3"> <p class="flow-text">"@Html.DisplayFor(model => item.ReviewText)"</p> </div> </div> <div class="row"> <div class="col s3"> <p>Date Created : @Html.DisplayFor(modelItem => item.CreatedDate)</p> </div> <div class="col s3"> <p>Chosen Display Name: @Html.DisplayFor(modelItem => item.DisplayName)</p> </div> </div> </div> <hr /> } </div>

我认为这可能是因为它的孩子试图更新父母,但我找不到任何信息。我尝试将分页放在目标div之外,所有发生的事情都是当页面> 1时页面永远不会更新。

I thought that it may be because its a child trying to update a parent, but I cant find any info. I tried to put pagination outside of the target div, all that happend was the pagination never got updated when there were pages >1.

我是新手,只有到目前为止,已经制作了没有ajax的网站!我想过滤器/整理,但我在这里继续绕圈子,我甚至尝试了一个不同的nuget包用于分页链接到git ,仍然没有快乐!就像我说的那样,下一页是在回复中,但它并没有取代那里的。

I'm new to this, only having made websites without ajax, until now! I figured the filter/sorting out, but I keep going around in circles here, I even tried a diferent nuget package for pagination Link to git, still no joy! Like I say, the next page is in the response, but it doesn't replace whats there.

谢谢:)

推荐答案

想出来......在data-ajax-update =filter我需要添加元素id前面的#标签符号,例如data-ajax-update =#filter... facepalm

Figured it out... in the data-ajax-update="filter" I needed to add a hashtag infront of the element id e.g. data-ajax-update="#filter"... facepalm

更多推荐

Pagnation没有更新目标

本文发布于:2023-11-05 07:58:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目标   Pagnation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!