When e.preventDefault() is not preventing....

3 posts, 0 answers
  1. nachid
    nachid avatar
    190 posts
    Member since:
    Mar 2010

    Posted 02 Jul 2012 Link to this post

    I am doing this directly on the ajax demo page. so you can test it for yourself.
    I used firebug console and I binded a select hander on the panelbar.
    $("#panelbar").data('kendoPanelBar').bind('select', function (e) { e.preventDefault(); });
    You can see when you click on a panel, it is expanded and the underlying ajax call is made
    The preventDefault is not taken into account.

    I had to use recursion to make work as it is supposed to
    var event= $("#panelbar").data('kendoPanelBar').bind('select', function (e) { event.preventDefault(); });


  2. Kevin
    Kevin avatar
    2 posts
    Member since:
    Feb 2013

    Posted 21 Apr 2016 in reply to nachid Link to this post

    I was trying this out, as I also wanted to disable selection in the panelbar.  e.preventDefault() didn't work, even with the recursive technique.  The following worked for me:

    var panelbar = $("#panelbar").data('kendoPanelBar');
    panelbar.bind('select', function(e) { panelbar.clearSelection(); });

    (Note: I just wanted to disable selection, not expansion.)

  3. John
    John avatar
    4 posts
    Member since:
    May 2018

    Posted 28 Sep Link to this post

    try having your function return false instead of calling e.preventdefault.  I've had to do that when adding an event to the grid refresh button.
Back to Top