A couple of things

Oct 1, 2013 at 5:39 PM
Edited Oct 2, 2013 at 12:24 AM
Dont suppose you could help me with a couple of things. First when i change the route of topics around {id}-{name} instead the javascript pager doesnt work, does something need to be altered

Also im trying to add the javascript pager to other pages, eg Latest Topics page, What needs editing in pager.js for this to work

Much appreciated if you can help

<div id="pagerClient" style="display:none;"><a class="bttn darkgrey" onclick="pager.more();return false;">@T("Show More")</a>@T(" ")<a class="bttn darkgrey" onclick="return pager.showAll();">@T("Show All")</a></div>
@Html.Pager(Config.UI.TopicsPerPage, this.PageIndex, (int)ViewData["TotalTopics"], S(" "), S(" "))
<script type="text/javascript">
   $(document).ready(function () {
       pager.init('@Url.Action("PageMore", "Forums", new { id = Model.Id })', '@Url.Action("PageUntil", "Forums", new { id = Model.Id })', '@T("The browser has lost session, click ok to return to the login page")');
controllers work if i make route allow me to put firstmsg and lastmsg into url it shows correct msgs, it doesnt work tho on list
Oct 2, 2013 at 12:22 AM
ive done this in forumscontroller

#region Client Paging
    /// <summary>
    /// Gets an amount (by config) of message items starting from index
    /// </summary>
    public ActionResult PageMore(int from)
        int userid;
        if (User != null) { userid = User.Id; } else { userid = 0; }
        var f = _service.Get("all");
        var forum = _topicService.GetLatest(userid, f.Id, from, Config.UI.TopicsPerPage, Role);
        if (forum == null)
            return ResultHelper.NotFoundResult(this);

        return View(false, forum);

    public ActionResult PageUntil(int firstMsg, int lastMsg)
        int userid;
        if (User != null) { userid = User.Id; } else { userid = 0; }
        var f = _service.Get("all");
        var forum = _topicService.GetLatest(userid, f.Id, firstMsg, ((int)lastMsg) - firstMsg, Role);
        if (forum == null)
            return ResultHelper.NotFoundResult(this);

        return View(false, "PageMore", forum);
Oct 2, 2013 at 9:25 AM
Edited Oct 2, 2013 at 9:25 AM
added this to forums detail, still doesnt work tho. atleast shows properly now
<div class="pagerSummary">
        @T("Displaying <span class=\"firstItem\">{0}</span> to <span class=\"lastItem\">{1}</span> of <span class=\"totalItems\">{2}</span> topics",
            PageIndex * Config.UI.TopicsPerPage + 1,
            PageIndex * Config.UI.TopicsPerPage + Model.Topics.Count,
Oct 4, 2013 at 8:27 AM
Hi Adam,
What do you mean it doesn't work?
On the server side:
  • Have you created the routing and the views for the new actions?
  • Have you tried requesting this new action on the browser and do they work correctly?
On the client side:
  • Are you having javascript runtime errors?
  • Have you tried debugging the javascript using Firebug?
Kind Regards,
Oct 4, 2013 at 10:48 AM
Hey, yeah ive created the routes for the views, the views work fine when i set variables in the url with constraints and they show perfect.

No javascript errors but in firebug it said
TypeError: $(...).attr(...) is undefined

var fromId = $("#messages > li:last").attr("id").substring(3);
Oct 4, 2013 at 10:52 AM
Edited Oct 4, 2013 at 10:52 AM
Because the pager, designed to work for the message list, looks for $("#messages > li:last") and these elements dont exist...
Or you either adapt a lot of parts in the pager.js file or it wont work as is...
Oct 4, 2013 at 10:59 AM
i see what this means, its the <li id="msg@(Model.Id)"> part.

But the topics pages dont count up for one and if a topic gets deleted the numbers change, tried a count using a viewbag and that didnt work, still same error. hmm
Oct 4, 2013 at 11:00 AM
yeah cheers jorge didnt refresh page, ill have to come up with something. Never even knew of firebug so cheers for that, will come in handy!
Oct 4, 2013 at 11:02 AM
As you say, the approach used for messages is not valid for the topics pagination.

You are half way there :)
I recommend you to create a different script for handling topic client paging (based on the messages one, but not the same).

Good luck!!!