@@ -202,10 +202,12 @@ $(document).ready(function () {
202202 function navigateToPage ( inputElement ) {
203203 const pageInfo = table . page . info ( ) ;
204204 const pageNum = parseInt ( inputElement . value , 10 ) ;
205- if ( pageNum >= 1 && pageNum <= pageInfo . pages ) {
205+
206+ // Check for valid number and range
207+ if ( ! isNaN ( pageNum ) && pageNum >= 1 && pageNum <= pageInfo . pages ) {
206208 table . page ( pageNum - 1 ) . draw ( false ) ;
207209 } else {
208- // Reset to current page if invalid
210+ // Reset to current page if invalid or out of range
209211 inputElement . value = pageInfo . page + 1 ;
210212 }
211213 }
@@ -222,6 +224,18 @@ $(document).ready(function () {
222224 pageInput . addEventListener ( 'blur' , function ( ) {
223225 navigateToPage ( this ) ;
224226 } ) ;
227+
228+ // Update page jump on table redraw
229+ table . on ( 'draw.dt' , function ( ) {
230+ const pageInfo = table . page . info ( ) ;
231+ pageInput . value = pageInfo . page + 1 ;
232+ pageInput . max = pageInfo . pages ;
233+
234+ const totalSpan = document . querySelector ( '.page-jump-total' ) ;
235+ if ( totalSpan ) {
236+ totalSpan . textContent = `of ${ pageInfo . pages } ` ;
237+ }
238+ } ) ;
225239 }
226240
227241 console . log ( '[ChatLog] addPageJump complete' ) ;
@@ -230,21 +244,6 @@ $(document).ready(function () {
230244 }
231245 }
232246
233- // Update page jump on page change
234- table . on ( 'draw.dt' , function ( ) {
235- const pageInput = document . getElementById ( 'pageJumpInput' ) ;
236- if ( pageInput ) {
237- const pageInfo = table . page . info ( ) ;
238- pageInput . value = pageInfo . page + 1 ;
239- pageInput . max = pageInfo . pages ;
240-
241- const totalSpan = document . querySelector ( '.page-jump-total' ) ;
242- if ( totalSpan ) {
243- totalSpan . textContent = `of ${ pageInfo . pages } ` ;
244- }
245- }
246- } ) ;
247-
248247 // Run after DataTables initialization to avoid timing issues
249248 table . on ( 'init.dt' , function ( ) {
250249 relocateSearch ( ) ;
0 commit comments