Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81688

Why is a delay need for fnPageChange?

$
0
0
Hey all,

I'm running into a strange issue, and it's happening across a few sites I maintain that use datatables.

Whenever I utilize fnPageChange, it does not work unless there is a setTimeout around it like this;

setTimeout(function() { oTable.fnPageChange(whatPage); }, 100);

or with an alert before it
alert('starting'); oTable.fnPageChange('last');

I understand this may be a sequence error of some sort, but I'm just unsure why the same issue would arise across multiple projects.

Here is the delete function I'm working with now:

function fnDelete(elem){
        if (selected.length>0) {
            var c;
            c = confirm('Are you sure you want to delete the selected ${displayTableName}?');
            if (c) {
                // Create delete url from editor url...
                var deleteURL = (urlstr.substring(0, urlstr.lastIndexOf('/') + 1)) + "delete.do";
                deleteRecord(deleteURL,selected[0]);
                
                if ( $('tableViewer tr').length === 0) {
                    // Reload the Table
                    oTable.fnPageChange('last');
                    //Send them back to the last page
                }
            }
        }

    }

Does anyone know what the issue is?

Viewing all articles
Browse latest Browse all 81688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>