As recommend by various performance optimization tools my webpages all include the JQuery reference at the end of the page. Lately, I've been introducing JQuery code into my partial views. Since JQuery is not referenced yet, how can I use JQuery throughout my page in partial views?
UPDATE: Here's something I'm trying to do. This is in a partial view.
@model pending.Models.WidgetZone
<fieldset id="fieldset_Available-Widgets_@(Model.Slug)" class="available-widgets">
<legend>@i18n.widgets_availableWidgetsList</legend>
@Html.Action(MVC.Admin.WidgetFramework.Select(Model.Slug))
@{
string ddlId = "#select_Available-Widgets_" + @Model.Slug;
string pageId = ViewContext.RouteData.Values["id"].ToString();
}
<p>
@* <input type="button" value="@i18n.widgets_AddWidget" id="btn_AddWidget_@Model.Slug" onclick="pending.widgetAdmin.addWidget($('@ddlId').val(), '@Model.Slug', '@pageId')" />*@
<input type="button" value="@i18n.widgets_AddWidget" id="btn_AddWidget_@(Model.Slug)" />
</p>
</fieldset>
@section js_placeholder {
<script type="text/javascript">
$('#btn_AddWidget_@(Model.Slug)').click(function () {
pending.widgetAdmin.addWidget($('@ddlId').val(), '@Model.Slug', '@pageId');
});
</script>
}
As you can see I have some JQuery selecting code in there that requires JQuery in the <head>
of the page. I've already tried implementing Darin's suggestion (see @section
) but it doesn't render anything.