Jquery datatable - Selected row hightlight issue

Jquery datatable - Selected row hightlight issue

jquerydatatablejquerydatatable Posts: 5Questions: 0Answers: 0
edited July 2013 in General
In my datatable, getting result from search button action. So first search results selected row hightlight working good , but again search those results are not highlighting .why second time selected row high light is not working good ? Please advise...

This demo not simulated the issue which i mention , but similar way the works datatable..


[1]: http://jsfiddle.net/rwPFx/34/

$('#products1 tbody tr').live("click", function () {

if ($(this).hasClass('selected1')) $(this).removeClass('selected1');
else
{

$(this).siblings('.selected1').removeClass('selected1');
$(this).addClass('selected1');
}

$("#dialog-form").data('rows', oTable.fnGetData( this ));

});

Replies

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Hi,

    Thanks for the link to the JSFiddle page. The problem that you are encountering is that the event handler is being added to the page multiple times - every time the search button is clicked in fact.

    The result is that the click handler will fire multiple times. So for example, if you click search once, the event handlers is added once. Click it again and the event handler is there twice. Then if you click a row in the table, it gets selected by the first event handler, and then deselected by the second!

    So you just want to attach the event handler once:
    http://jsfiddle.net/rwPFx/39/

    Regards,
    Allan
  • jquerydatatablejquerydatatable Posts: 5Questions: 0Answers: 0
    edited July 2013
    Thanks for comment. Click the search button and getting search result, but click again search its getting change the order result, but number result same. why is this happening while click search button and if click search the width of result in table reducing per each click ?
  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Hi,

    I'm afraid I don't quite understand - sorry. One the second click of the "Search" button, nothing will change in the example you linked to since the data used for the table is the same.

    Allan
This discussion has been closed.