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

Autocomplete in partial view loaded by ajax.actionlink not working

1 Answer 316 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 28 Nov 2016, 08:29 AM

Dear,

We have tried to add autocomplete dynamically from partial view with Ajax.ActionLink, but they do not initialize, and not working.
We also managed to use different id-s on the inputs, but we standardize the name for achive out goal:

Dynamic load of partial view:
  @Html.Partial("_Teszt", Model)
        <div id="tobbSpecEszkoDiv">
        </div>
        @Ajax.ActionLink(
            "Új",
            "_Teszt",
            "Home",
            new AjaxOptions
            {
                UpdateTargetId = "tobbSpecEszkoDiv",
                InsertionMode = InsertionMode.InsertAfter,
                OnSuccess = "korteLo"
            })

<script language="javascript">
    function korteLo(e) {
        $("input[id^='countries']").attr('name', 'countries');;
    }
</script>

 

PartialView:

@using Kendo.Mvc.UI
@(Html.Kendo().AutoComplete()
          .Name("countries"+DateTime.Now.Millisecond)
          .Filter("startswith")
          .Placeholder("Select country...")
          .BindTo(new string[] {
                "Albania",
                "Andorra",
                "Armenia",
                "Austria",
                "Azerbaijan",
                "Belarus",
                "Belgium",
          })
          .Separator(", ")
      )

 

For further details we attached the project files.

 

Best regards.

1 Answer, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 28 Nov 2016, 11:23 AM
Hello,

From the provided demo project I presume that you want the AutoCompleteBox to be populated with the data passed to the partial view in the _Teszt Action. In order to do that please edit your code as in the example below:

@(Html.Kendo().AutoComplete()
          .Name("countries" + DateTime.Now.Millisecond)
          .Filter("startswith")
          .Placeholder("Select country...")
          .BindTo(@Model)
          .Separator(", ")
)

And last, but not least, I would ask you avoiding threads duplication for an issue, which allows us to provide you with better support.

Regards,
Anton
Telerik by Progress
Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Tags
AutoComplete
Asked by
Peter
Top achievements
Rank 1
Answers by
Anton
Telerik team
Share this question
or