I’m trying to build a pager where it’s just Next / Previous buttons that call a jquery function that post a JSON request. Inside the function, the current page “index” is retrieved from a hidden field and passed to the controller. Inside the controller, I reset the index if I’m on the last page of data. How would I pass the new index value back to the view? Or is there a better way to do what i’m trying to do?
Thanks
Daniel Shaffer is right, you should not re-invent the wheel.
But if you really want to do it yourself: I assume you are using the jquery load() method or something similar to dynamically load the new list content and then insert the new code into the page.
In that case, if you want to reset your index counter, you can simply use a document ready handler:
If this looks confusing, it’s because <%=Model.NewCounterValue%> is a server-side tag embedded in a javascript block. You’ll get used to it 🙂
As soon as you insert this into your DOM, the document.ready handler is executed, just as it would be on a regular web page.