refresh javascript on Page Next / Back

refresh javascript on Page Next / Back

gingging Posts: 1Questions: 0Answers: 0
edited February 2010 in General
Hi I was wondering if there was a way to refresh the javascript on my page. I have a link in one of my 's that opens up a overlay. This only works on the first page of data and if I go to the next page it doesn't work. My code is below. I know it's probably an easy solution. I'm definitely a newbie at javascript. Any help would be greatly appreciated.

I'm using the codeidniter framework.





[code]



$(document).ready(function() {
$('#example').dataTable( {
"sDom": '<"top"i>rt<"bottom"flp<"clear">'
} );
} );










Last Name
First Name
Phone
Cell Phone
email








<?php

foreach ($result as $row) {


echo '' .
'' . $row->last_name . '' .
'' . $row->first_name . '' .
'' . $row->phone . '' .
'' . $row->cell_phone . '' .
''.$row->email.'' .
'view'.
'edit'.
'delete'.
'';


}
?>



Last Name
First Name
Phone
Cell Phone
email









<!-- overlayed element -->


<!-- the external content is loaded inside this tag -->




<!-- make all links with the 'rel' attribute open overlays -->


$(function() {

// if the function argument is given to overlay,
// it is assumed to be the onBeforeLoad event listener
$("a[rel]").overlay({

expose: 'black',
effect: 'apple',

onBeforeLoad: function() {

// grab wrapper element inside content
var wrap = this.getContent().find(".contentWrap");

// load the page specified in the trigger
wrap.load(this.getTrigger().attr("href"));
}

});
});


[/code]

Replies

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    The problem you are having here is that you are initialising the table first and then adding the events for the overlay - so they are only being attached to the first 'page'. Have a look at this example for how to get around this:
    http://datatables.net/examples/advanced_init/events_post_init.html

    Should be as simple as storing a global variable to the table and then using $("a[rel]", oTable.fnGetNodes()).overlay({...});

    Or you can initialise the DataTable after the overlay:
    http://datatables.net/examples/advanced_init/events_pre_init.html

    Allan
This discussion has been closed.