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

Kendo button to pass arguments to Javascript function

3 Answers 3445 Views
Button
This is a migrated thread and some comments may be shown as answers.
prakash
Top achievements
Rank 1
prakash asked on 19 Feb 2015, 09:17 AM
I am using kendo button the following way.

    @(Html.Kendo().Button().Name("deleteButton").HtmlAttributes(new { type = "button", @class = "k-primary pull-right" }).Content("Delete").Events(ev => ev.Click("Delete(1)")))

I need to call a javascript function with parameters

        function Delete(value)
        {
            alert(value)
        }

But it doesn't work when I click the button.
Everything works fine without arguments.

Does telerik support passing arguments to javascript functions from buttons?

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 20 Feb 2015, 11:25 AM

Hello Prakash,

You could add it as a custom attribute to the button element and then retrieve it in the handler.
E.g.

.HtmlAttributes( new {type = "button", param="5"} )

function onClick(){
    var param = this.element.attr("param");
}

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
prakash
Top achievements
Rank 1
answered on 20 Feb 2015, 12:32 PM
That worked :)
Thanks.
It would be really helpful if these are documented (or did I just didn't find it !!)
0
Dimiter Madjarov
Telerik team
answered on 20 Feb 2015, 12:36 PM

Hello Prakash,

I am glad the issue is resolved.

Thanks for the suggestion, I will pass it to the documentation team.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Button
Asked by
prakash
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
prakash
Top achievements
Rank 1
Share this question
or