jQuery Masonry and Ajax Append Items?

前端 未结 13 1427
借酒劲吻你
借酒劲吻你 2020-12-08 07:19

I am trying to use some ajax and the jQuery Masonry plugin to add some items - but for some reason the new items aren\'t getting the masonry applied ?

I\'m using

13条回答
  •  孤街浪徒
    2020-12-08 07:38

    Following has worked for me. I have an ajax which returns set of html items (returns a partial view, from the ajax) when I click a load more button in my web page. Below is the partial view, which is dynamically generated.

    foreach (var item in Model.SocialFeedList)
    {
            

    TitleOfTheLink

    SomeDescription

    Published: 2016/07/13
    }

    In the success callback ajax method, I have done the below,where "response" is the set of html items I get from the above html. Where "divFeedList" is the root element where I show the set of html elements.

    jQuery("divFeedList").append(response).masonry('reloadItems', response, true).masonry();

    Please let me know if the answer is unclear.

提交回复
热议问题