javascript - jquery.simplePagination.js:334 Uncaught TypeError: Cannot set property 'currentPage' of null -
hello im getting error in browser, function working intetend im curious of why im getting error, can see becasue sets currentpage value null dont understand why thats problem. paging works fine im want know if can solved error. im rookie.
jquery.simplepagination.js:334 uncaught typeerror: cannot set property 'currentpage' of null @ init._selectpage (jquery.simplepagination.js:334) @ init.selectpage (jquery.simplepagination.js:66) @ init.$.fn.pagination (jquery.simplepagination.js:389) @ checkfragment (blog:440) @ htmldocument.<anonymous> (blog:447) @ c (jquery.min.js:4) @ object.firewith [as resolvewith] (jquery.min.js:4) @ function.ready (jquery.min.js:4) @ htmldocument.q (jquery.min.js:4)
<script src="~/scripts/jquery.simplepagination.js"></script> <script> // mind slight change below, personal idea of best practices jquery(function ($) { // consider adding id table, // incase second table ever enters picture..? var items = $("article"); var numitems = items.length; var perpage = 2; // show first 2 (or "first per_page") items items.slice(perpage).hide(); // setup pagination // need .pagination-page div before/after table if (numitems > 2) { $(".pagination-page").pagination({ items: numitems, itemsonpage: perpage, cssstyle: "light-theme", onpageclick: function (pagenumber) { // magic happens // changed page, lets hide/show trs appropriately var showfrom = perpage * (pagenumber - 1); var showto = showfrom + perpage; items.hide() // first hide everything, show new page .slice(showfrom, showto).show(); } }); } // edit: stuff cover url fragments (i.e. #page-3) // https://github.com/bilalakil/bin/tree/master/simplepagination/page-fragment // more thoroughly commented (to explain regular expression) // we'll create function check url fragment , change page // we're storing function in variable can reuse var checkfragment = function () { // if there's no hash, make sure go page 1 var hash = window.location.hash || "#page-1"; // we'll use regex check hash string hash = hash.match(/^#page-(\d+)$/); if (hash) // selectpage function described in documentation // we've captured page number in regex group: (\d+) $("#pagination").pagination("selectpage", parseint(hash[1])); }; // we'll call function whenever back/forward pressed $(window).bind("popstate", checkfragment); // , we'll call check right now! checkfragment(); }); </script>
using: http://flaviusmatis.github.io/simplepagination.js/
if have better solution foreach pagnation function please let me know.
Comments
Post a Comment