简体   繁体   English

在MVC4部分视图中使用PagedList时的不良行为

[英]Undesired behaviour when using PagedList in an MVC4 partial view

I have a partial view that displays a number of search results from a list. 我有一个局部视图,可显示列表中的许多搜索结果。 For aesthetic reasons, I display the results two list items per row: 出于美学原因,我将结果显示为每行两个列表项:

list item 1 | 列表项1 | list item 2 清单2

list item 3 | 清单3 | list item 4 清单项目4

etc.... 等等....

I'm implementing paging with PagedList, and since it's a partial view I'm using Ajax.ActionLink s to navigate each 'paged list'. 我正在使用PagedList实现分页,并且由于它是局部视图,因此我使用Ajax.ActionLink来导航每个“分页列表”。 Eg: 例如:

@Ajax.ActionLink("<<", "GetAllProperties", new { page = 1 }, new AjaxOptions { UpdateTargetId = "quick-property-search-results" })

When the page loads, all items from the list are displayed correctly - two list items per row. 页面加载后,列表中的所有项目都会正确显示-每行两个列表项目。 However when I click Next > , the next items are displayed but the formatting goes off, like this: 但是,当我单击Next > ,将显示下一个项目,但格式不可用,如下所示:

list item 1 清单项目1

list item 2 清单2

list item 3 清单项目3

etc... 等等...

I tried passing the css class that actually gives me the two-list-items-per-row layout as html attributes to the ActionLinks, but it didn't help. 我尝试将css类传递给ActionLinks,该类实际上为我提供了每行两个列表项的布局作为html属性,但没有帮助。

Does anyone know what's causing this behaviour - and how to remedy it? 有谁知道是什么原因导致这种行为-以及如何解决?

Edit: added css class and razor code. 编辑:添加了CSS类和剃刀代码。

.result-container { 
    border: 3px solid #999;
    padding: 5px;
    margin-bottom: 5px;
    margin-right: 5px;
    width: 563px; 
    float: left; 
    height:130px;
}


@foreach (var result in Model)
{
    <div class="result-container">
    // output model data...
    </div>
}

What does the generated markup look like for @Ajax.ActionLink? @ Ajax.ActionLink生成的标记是什么样的? I'm guessing it's a matter of binding to your dynamic content after your ajax call. 我猜这是在ajax调用之后绑定到动态内容的问题。 In jquery, you'd use the .on event vs the .click event. 在jquery中,您将使用.on事件与.click事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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