fnDrawCallback problem facebox

fnDrawCallback problem facebox

davisvasconcellosdavisvasconcellos Posts: 12Questions: 2Answers: 0
edited March 2013 in General
Works fine at the first load, but in any datatables events , plugins reload more instances..

Script:
$(document).ready( function() {
$('#contactList').dataTable({
/* Disable initial sort */
"aaSorting": [],
"bRetrieve": false,
"bDestroy":true,
"fnDrawCallback": function( oSettings ) {
$("*[rel=facebox]").facebox ();
}
});
})

html:

<%=rsContatos("apelido")%>




in first time if i click. popup facebox appears correctly with only one content
johnDoe [Click to details] -> popup apears:
[username:bla, email:bla@email.com, cel:bla ]

so if i click on next and go back.
johnDoe [Click to details] -> popup apears:
[username:bla, email:bla@email.com, cel:bla ]
[username:bla, email:bla@email.com, cel:bla ]

click on next go back again
[username:bla, email:bla@email.com, cel:bla ]
[username:bla, email:bla@email.com, cel:bla ]
[username:bla, email:bla@email.com, cel:bla ]

search john(see 4 chars) and click on result
[username:bla, email:bla@email.com, cel:bla ]
[username:bla, email:bla@email.com, cel:bla ]
[username:bla, email:bla@email.com, cel:bla ]
[username:bla, email:bla@email.com, cel:bla ]


I am SAD and crazy
Whats wrong?

Thanks

Replies

  • allanallan Posts: 63,508Questions: 1Answers: 10,471 Site admin
    fnDrawCallback fires on every draw- so the code runs every draw - so you are initialising facebox multiple times.

    I'd suggest you just use fnInitComplete .

    Allan
  • davisvasconcellosdavisvasconcellos Posts: 12Questions: 2Answers: 0
    i go to test.
    thanks
  • davisvasconcellosdavisvasconcellos Posts: 12Questions: 2Answers: 0
    not work.
    now only first page work.
    $(document).ready( function() {
    var oTable = $("#example2").dataTable({
    "fnInitComplete": function(oSettings) {
    $("*[rel=facebox]").facebox ();
    }

    } );
    } );
  • allanallan Posts: 63,508Questions: 1Answers: 10,471 Site admin
    Try:

    [code]
    $("*[rel=facebox]", this.fnGetNodes()).facebox();
    [/code]

    Allan
  • davisvasconcellosdavisvasconcellos Posts: 12Questions: 2Answers: 0
    NICE.
    GENIUS.
    THANKS
This discussion has been closed.