changes to the next previous example

changes to the next previous example

isport59isport59 Posts: 30Questions: 9Answers: 2

I did some changes to the next previous example. I have an alert() when it reaches the last file but i'd rather have the prev and next button to be disable when it reaches past the first and last record.

Here is my page:
http://editor.uhmind.com/examples/api/backNext.html

Here are the code changes

                        {
                        label: "<",
                        fn: function (e) {
                            this.submit( function () {
                                var tt = $.fn.dataTable.TableTools.fnGetInstance('example');
                                var row = tt.fnGetSelected()[0];
                                var rows = table.rows( {filter:'applied'} ).nodes();
                                var index = rows.indexOf( row );
                                // added a conditional
                                if( index == 0 ) {
                                    alert('last record');
                                    tt.fnDeselect( row );
                                    tt.fnSelect( rows[index] );
                                    $('a.editor_edit').click();
                                }
                                // did some change here also
                                if ( index > 0 ) {
                                    tt.fnDeselect( row );
                                    tt.fnSelect( rows[index-1] );
                                    $('a.editor_edit').click();
                                }

                            }, null, null, false );
                        }
                                                   {
                                                   label: ">",
                        fn: function (e) {
                            this.submit( function () {
                                var tt = $.fn.dataTable.TableTools.fnGetInstance('example');
                                var row = tt.fnGetSelected()[0];
                                var rows = table.rows( {filter:'applied'} ).nodes();
                                var index = rows.indexOf( row );

                                // added conditional
                                if( index == rows.length-1 ) {
                                    alert('last record');
                                    tt.fnDeselect( row );
                                    tt.fnSelect( rows[index] );
                                    $('a.editor_edit').click();
                                }
                                // made changes here also
                                if ( index < rows.length-1 ) {
                                    tt.fnDeselect( row );
                                    tt.fnSelect( rows[index+1] );
                                    $('a.editor_edit').click();
                                }
                            }, null, null, false );
                        }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    Thanks for posting this - looks like a nice update! I'll look at integrating this feature into the demo.

    Allan

This discussion has been closed.