最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to call a function when custom toolbar is clicked in Kendo UI? - Stack Overflow

programmeradmin3浏览0评论

I want to create a custom toolbar. Here is my code:

toolbar:[{
    text: "Go to Add User Page",
    className: "k-grid-custom",
    imageClass: "k-add"
}],

function createUser(){
    alert('Hello World');
}

I want to call the function named createUser when this button(custom toolbar) is clicked. How to make it possible?

I want to create a custom toolbar. Here is my code:

toolbar:[{
    text: "Go to Add User Page",
    className: "k-grid-custom",
    imageClass: "k-add"
}],

function createUser(){
    alert('Hello World');
}

I want to call the function named createUser when this button(custom toolbar) is clicked. How to make it possible?

Share Improve this question asked Aug 13, 2012 at 22:09 Johndave DecanoJohndave Decano 2,1132 gold badges16 silver badges16 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

You could add a unique class to the button and then use that class to bind to the click event.

toolbar:[{
    text: "Go to Add User Page",
    className: "myCustomClass",
    imageClass: "k-add"
}],

$(".myCustomClass").click(function() {
    alert("Click!");
});
function test(e){
      return '<a class="k-button" href="#" id="toolbar-add_user" onclick="test_fn()">Add User</a>';
 };
function test_fn(){
        window.location = "http://www.google.";
};
 toolbar:[{
        name:'add_user',
        template:'#= test()#'
}],
  1. First i had to make a function to be able to customize the button and add an onclick event.
  2. Then i had to make a new function to listen to the event.
发布评论

评论列表(0)

  1. 暂无评论