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

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

1 Answer 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Veteran
Scott asked on 14 Feb 2020, 02:52 PM

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!");

} )

1 Answer, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
Veteran
answered on 14 Feb 2020, 06:42 PM

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!') }"))

Tags
General Discussions
Asked by
Scott
Top achievements
Rank 1
Veteran
Answers by
Scott
Top achievements
Rank 1
Veteran
Share this question
or