tags:

views:

91

answers:

2

I am using the Telerik autocomplete option

In the header:

<script type="text/javascript">
function onAutoCompleteDataBinding(e) {
  var autocomplete = $('#AutoComplete').data('tAutoComplete');
  autocomplete.dataBind(["Product 1", "Product 2", "Product 3"]}
</script>

In the body of the View:

<%=Html.Telerik().AutoComplete()
  .Name("AutoComplete")
  .ClientEvents(events => events.OnDataBinding("onAutoCompleteDataBinding"))
%>

http://demos.telerik.com/aspnet-mvc/combobox/clientsidebinding

I have managed to get this working on other applications and it is really quite simple. I have pasted this example on top to show that this one also bombs out on :

 this.trigger = new $t.list.trigger(this);

Think i might have mixed up the .js files and now my auto complete is not working. Any sugesions which js files and in what order they must be for this to work right

My Page master relevant parts:

<body>
    <% Html.Telerik().ScriptRegistrar()
            .DefaultGroup(group => group
                .Add("MicrosoftAjax.js")
                .Add("MicrosoftMvcAjax.js")
            );
    %>
        <div class="MainTableBody">
            <asp:ContentPlaceHolder ID="ContentPlaceHolder" runat="server" />
        </div>

    <% Html.Telerik().ScriptRegistrar().Render(); %>
</body>
</html>

In my web.config

<add namespace="Telerik.Web.Mvc.UI" />

Any help or comments would be greatly appreciated

A: 

Hi,

I am not exactly sure, but I think that the telerik.list.js file is not loaded. Check if the required javascript files are loaded. Here is a help topic, which shows required javascript files per component. You can verify which files are loaded using ViewSource... method of the browser (FF for instance) and look at the end of the page.

George K
Hi George, thankyou for the information..thought that was one of the reasons and did the whole update each and every part required.
Roachmans
+1  A: 

Found the problem,

MVC 3 little bug, you need to put all the namespaces in the web.config and not have them on your views in mvc.

Was like this in my view.master

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>

The solution was, take it out of the master page and add it to your web.config so that master page only has:

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>

and web.config has:

<pages>
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="Telerik.Web.Mvc.UI" />
     </namespaces>
</pages>
Roachmans