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

AutoComplete Data-Bind html attributes

1 Answer 311 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Gregor
Top achievements
Rank 1
Gregor asked on 14 Sep 2012, 09:16 AM
Id like to extend to the AutoComplete helper to pass in a data-bding html 5 attribute, I have the following:-

@(Html.Kendo().AutoComplete()
          .Name("productAutoComplete")
          .DataTextField("id")
          .DataTextField("name")
          .DataSource(source =>
              {
                  source.Read(read =>
                      {
                          read.Action("ProductSuggestions", "Search")
                            .Data("onAdditionalData").Type(HttpVerbs.Get);
                      }).ServerFiltering(true);
              })
              .Enable(true)
    )

I want to be able to add a new HtmlAttrobute something like this:-

.HtmlAttributes(new[] { "data-bind='executeOnEnter: products'" })

So that I can use a knockoutJS custom binding - can anyone help me with this?

1 Answer, 1 is accepted

Sort by
0
kashyapa
Top achievements
Rank 1
answered on 16 Oct 2012, 06:46 PM
Here's what you need to do to achieve that :

@(Html.Kendo().AutoCompleteFor(model => model.Person.State.Abbreviation)
                     .BindTo(Model.States)
                     .DataTextField("Abbreviation")
                     .HtmlAttributes(new { data_bind="executeOnEnter:products" })
        )

Tags
AutoComplete
Asked by
Gregor
Top achievements
Rank 1
Answers by
kashyapa
Top achievements
Rank 1
Share this question
or