Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET MVC > General Discussions > Can't include JS file for view

Not answered Can't include JS file for view

Feed from this thread
  • Dewey avatar

    Posted on Feb 1, 2012 (permalink)

    I am attempting to add a script for my view by declaring a second ScriptRegistrar in the view.  The view uses a layout on which the Default ScriptRegistrar resides. Here is excerpts from the rendered page:

    <head>
     
        (head stuff here)
     
    <script type="text/javascript" src="/Myapp/asset.axd?id=aQMAAB-..."></script>
    <script type="text/javascript" src="/Myapp/Scripts/Shared/Manual.js"></script>
    <script type="text/javascript">
    //<![CDATA[
    jQuery(document).ready(function(){
    jQuery('#Dropdownlist').tDropDownList({onChange:Dropdownlist_onChange, data:[{"Text":"","Value":"0"},...]});
    //]]>
    </script>
     
        <script type="text/javascript" src="/Myapp/Scripts/jquery.cookie.js"></script>
        <script type="text/javascript" src="/Myapp/Scripts/jquery.validate.js"></script>
     
    </head>
    <body>
     
    ...

    The error is occurring on the line that begins "jQuery('#Dropdownlist').  The error is:

    "Object doesn't support property or method 'Dropdownlist_onChange'

    It appears that the named function Dropdownlist_onChange in my "Manual.js" is not being loaded into the DOM.

    Right now I have located the following:

    @(Html.Telerik().ScriptRegistrar()
    .Scripts(x => x.AddGroup("Manual",  group => group
     .Add("~/Scripts/Shared/Manual.js"))))

    near the top of the view, before the dropdownlist. Why am I getting the error?

     

    Reply

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on Feb 6, 2012 (permalink)

    Hi,

     Everything looks correct and should have worked. You could check if the Manual.js file is successfully downloaded by the browser using an HTTP sniffing tool (FireBug or Fiddler).

    Regards,
    Atanas Korchev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET MVC > General Discussions > Can't include JS file for view