Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript not working within a view but works in the rest of the views in the application
    primarykey
    data
    text
    <p>I have a view which is referencing a Javascript file which contains an Auto Complete function. The problem is in this view the Javascript is not working at all. Even an alert on document.ready will not work. I can use the exact javascript file in a different view and it works perfectly. I do not know what is wrong with the following view. </p> <p><strong>VIEW</strong></p> <pre><code> @model RunLog.Domain.Entities.ErrorCode @{ ViewBag.Title = "Create"; Layout = "~/Views/Shared/_Layout.cshtml"; } &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt; @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;fieldset&gt; &lt;legend&gt;Enter a new Error Code&lt;/legend&gt;@*&lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Error ID") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.EditorFor(model =&gt; model.ID) &lt;/span&gt; &lt;/div&gt;*@ &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Error Description") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.TextBoxFor(model =&gt; model.ErrorDescription, new { style = "width: 500px;" }) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Parent ID") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.DropDownList("ParentID", String.Empty) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Error Description Complete") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.TextBoxFor(model =&gt; model.ErrorDescriptionWithParent, new { style = "width:500px;" }) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("High Level Error") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.TextBoxFor(model =&gt; model.highlevelerror, new { style = "width:500px;" }) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Error Number") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.EditorFor(model =&gt; model.ErrorNumber) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Track") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.EditorFor(model =&gt; model.track) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Lane") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.EditorFor(model =&gt; model.lane) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Subsystem") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.EditorFor(model =&gt; model.subsystem, new { id = "rootcause" }) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt; @Html.Label("Critical") &lt;/span&gt;&lt;span class="rightContent"&gt; @Html.EditorFor(model =&gt; model.critical) &lt;/span&gt; &lt;/div&gt; &lt;div class="bodyContent"&gt; &lt;span class="leftContent"&gt;&lt;/span&gt;&lt;span class="rightContent"&gt; &lt;input id="create" class="art-button" type="submit" value="Create" /&gt; &lt;/span&gt; &lt;/div&gt; &lt;/fieldset&gt; } &lt;div&gt; @Html.ActionLink("Back to List", "List") &lt;/div&gt; &lt;script type="text/javascript"&gt; var serviceRootCauseUrl = '@Url.Action("FindRootCause", "ServiceEntry")'; &lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/rootcause.js")" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p><strong>JAVASCRIPT FILE</strong></p> <pre><code>$(document).ready(function () { $("#rootcause").autocomplete({ source: function (request, response) { $.ajax({ url: serviceRootCauseUrl, type: "POST", dataType: "json", minLength: 0, data: { searchText: request.term, maxResult: 100 }, success: function (data) { response($.map(data, function (item) { return { label: item.FullName, value: item.RootCauseName, id: item.ID } })) } }) }, select: function (event, ui) { // $("#rootcause").text(selecteditem.text); // alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.id) // : "Nothing selected, input was " + this.value); } }); }); </code></pre> <p><strong>LAYOUT FILE</strong></p> <pre><code>&lt;title&gt;@ViewBag.Title&lt;/title&gt; &lt;link rel="stylesheet" href="@Url.Content("~/style.css")" type="text/css" media="screen" /&gt; &lt;!--[if IE 6]&gt;&lt;link rel="stylesheet" href="@Url.Content("~/style.ie6.css")" type="text/css" media="screen" /&gt;&lt;![endif]--&gt; &lt;!--[if IE 7]&gt;&lt;link rel="stylesheet" href="@Url.Content("~/style.ie7.css")" type="text/css" media="screen" /&gt;&lt;![endif]--&gt; &lt;link href="@Url.Content("~/Content/css/Site.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/css/main.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/css/Content.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/themes/base/jquery.ui.core.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/themes/base/jquery.ui.tabs.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/jquery.treeview.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/jquery-ui-timepicker-addon.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/themes/base/jquery.ui.dialog.css")" rel="stylesheet" type="text/css" /&gt; &lt;script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery-ui.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/jquery.cookie.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/scrolltable.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/grid.js")" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="@Url.Content("~/Scripts/datetime.js")" type="text/javascript"&gt;&lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload