How do I code an anonymous function for an event handler in the fluent syntax?

2 posts, 0 answers
  1. Scott
    Scott avatar
    24 posts
    Member since:
    Oct 2019

    Posted 14 Feb 2020 Link to this post

    Say I have a typical declaration like this:

     

    @(Html.Kendo().ComboBox().Name("cb")
         .DataTextField("Name")
         .DataValueField("ID")
         .DataSource(source => {
              source.Read(read => {
                    read.Action("GetTest", "Home");
               })
           .ServerFiltering(true);
           }).Events(e => e.Change("onCBChange"))

     

    How does the syntax look for replacing that e.Change("onCBChange") with an anonymous function? I'm thinking something like this, but I can't seem to get it right

     

    .Events(e => e.Change {

        function(f) { 

             alert("here!");

    } )

  2. Scott
    Scott avatar
    24 posts
    Member since:
    Oct 2019

    Posted 14 Feb 2020 Link to this post

    These forums are pretty dead, by the time you actually get an answer you've already figured it out for yourself.

    I stumbled upon this in another example since it doesn't appear to be documented but if someone else is looking for how to do it, you simply pass the entire text of the function in quotes, like this:

     

    .Events(e => e.Change("function(){ alert('eureka!') }"))

Back to Top