Kendo button to pass arguments to Javascript function

4 posts, 1 answers
  1. prakash
    prakash avatar
    8 posts
    Member since:
    Feb 2015

    Posted 19 Feb 2015 Link to this post

    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?
  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2157 posts

    Posted 20 Feb 2015 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. prakash
    prakash avatar
    8 posts
    Member since:
    Feb 2015

    Posted 20 Feb 2015 in reply to Dimiter Madjarov Link to this post

    That worked :)
    Thanks.
    It would be really helpful if these are documented (or did I just didn't find it !!)
  5. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2157 posts

    Posted 20 Feb 2015 Link to this post

    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.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready