Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
56
rated 0 times [  59] [ 3]  / answers: 1 / hits: 10526  / 10 Years ago, fri, november 7, 2014, 12:00:00

I've added the custom click handler for Kendo grid's Add new record button, but JavaScript's preventDefault() function does not seem to work on it.



$('.k-header').on('click', '.k-grid-add', function(e) {
e.preventDefault();
e.stopPropagation();
// do something else
});


I would like that Add new record button does something else than adds the new row in grid.



Full code example: JSFIDDLE


More From » jquery

 Answers
2

See updated fiddle



http://jsfiddle.net/qoxvaayn/5/



KendoUi also attached click event listener like jquery, so to remove an existing click event handler we should use off like below and then attach new click event.



e.preventDefault();e.stopPropagation(); will stop default event handler behavior but not attached listeners.



$('.k-header').off('click').on('click', '.k-grid-add', function(e) {
//handler business logic here
});

[#41415] Thursday, November 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
melindab

Total Points: 511
Total Questions: 109
Total Answers: 106

Location: San Marino
Member since Thu, Jun 25, 2020
4 Years ago
;