This is a migrated thread and some comments may be shown as answers.

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

2 Answers 1115 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
nachid
Top achievements
Rank 1
nachid asked on 02 Jul 2012, 09:21 AM
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 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 21 Apr 2016, 03:46 PM

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.)

0
John
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 28 Sep 2020, 02:16 PM
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.
Tags
PanelBar
Asked by
nachid
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
John
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or