Skip to content Skip to sidebar Skip to footer

Razor Model Helpers In Jquery/handlebars Infinite Scroll

I'm using MVC5 and originally had a standard MVC implementation with manual paging and all was well. Except, when I showed it to my friend, he's like 'What are all these number thi

Solution 1:

So far, I fixed it by moving my view logic (learned from nerddinner...which also makes me think of another question) to the controller, by simply adding the last two lines to my json result and returning them as bools:

var incidents = listPaged.Select(items =>new
        {
            items.IncidentId,
            items.Title,
            items.Description,
            items.Count,
            IsOwner = items.IsOwner(userName), // this oneIsSent = items.IsSent(userId) //and this one
        });

Then in handlebars, I did:

{{#unless IsOwner}}
   {{#if IsSent}}
     <div class="sent">Sent...</div>
   {{else}}
     <div class="sent">Not Sent...</div>
   {{/if}}
{{/unless}}

I tried to do the partial view with @Html.Action and a few other things that were really straining my mind how they could even possibly work. I like to keep things simple and the couple things I got to sort-of work were noticeably slower (~20%).

This fix is slightly faster too by about 10% on average. Maybe because I'm not pulling every field in the model now? Anyway, wish I could use those helpers in the template, but i can live with this, especially since it allows me to move on...

I'd love to hear any other opinions. Thanks.

Post a Comment for "Razor Model Helpers In Jquery/handlebars Infinite Scroll"