Help to customize events of paging

Help to customize events of paging

kalronfykalronfy Posts: 5Questions: 0Answers: 0
edited July 2011 in General
Hi,
My website have two types of user. I want to disable the users of one type clicking the pagination button. When they click, an alert box appear and no change for the current data displayed (but they can see the pagination button ). So they can only see the data of page one.

I try to bind the click event like below:
[code]
$('.paging_full_numbers span').live('click', function () {
alert('you can only see the content of page one!");
});
[/code]
it will popup a alert box, but still do paging operation.
How should I do ?

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    You could add in a return false; into your function which will stop the event bubbling. You would likely also want to unbind the event listeners that DataTables added by default, to make sure ($(...).unbind() and $(...).die()).

    Allan
  • kalronfykalronfy Posts: 5Questions: 0Answers: 0
    edited July 2011
    Thanks allan!

    I add return false after alert(); but the paging action is also fire. The version of datatable i use is 1.8.0
    [code]
    $('.paging_full_numbers span').live('click', function () {
    alert('you can only see the content of page one!");
    return false;
    });
    [/code]

    Why?
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Did you also unbind the event listeners that DataTables adds? You might need to do that before the above code? You might want to look at Visual Event to see what events are attached which which elements: http://sprymedia.co.uk/article/Visual+Event

    Allan
  • kalronfykalronfy Posts: 5Questions: 0Answers: 0
    That's a very nice tool. I unbind several event, but still not work.
    [code]

    $(document).ready(function() {
    otable = $('#example').dataTable( {...} );
    $('.paging_full_numbers span').unbind('click');
    $('.paging_full_numbers span').unbind('selectstart');
    $('.paging_full_numbers span').unbind('mousedown');
    $('.paging_full_numbers span').live('click', function () {
    alert('you can only see the content of page one!');
    return false;
    });
    });

    [/code]

    I am a beginner in javascript language, is there any error in the above code? Thanks
This discussion has been closed.