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

Using a custom template for a custom button on kendo ui editor

1 Answer 321 Views
Editor
This is a migrated thread and some comments may be shown as answers.
SupportTI
Top achievements
Rank 1
SupportTI asked on 17 Jul 2015, 09:18 PM

I'm trying to create a custom button for the kendo ui editor. The button works fine except when I try to use a custom template.
Here's the code for my custom button:

var currentDateAction = {
    name: 'currentDate',
    tooltip: vm.TemplateLetterCurrentDateLabel(),
    template: '<button class="k-button">' + vm.TemplateLetterCurrentDateLabel() + '</button>',
    exec: function () {
        var editor = $(this).data('kendoEditor');
        editor.exec('inserthtml', { value: vm.TemplateLetterCurrentDate() });
    }
};

If I comment the template line, the button works, otherwise it doesn't.
What do I have to do, to have a custom template for my button?

1 Answer, 1 is accepted

Sort by
0
Iliana Nikolova
Telerik team
answered on 21 Jul 2015, 03:46 PM
Hi,

When using a template you should attach a click handler to the button manually and use the handler function instead of exec. For example: 
$("#editor").kendoEditor({
    tools: [{
       name: 'currentDate',
       template: '<button class="k-button" onclick="buttonClick()">currentDate</button>',
       //....
     }]
});
 
function buttonClick(){
   //....
}

Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Editor
Asked by
SupportTI
Top achievements
Rank 1
Answers by
Iliana Nikolova
Telerik team
Share this question
or