2014-10-29 47 views
0

Ignite UI boilerplate將所有JavaScript文件加載到頁面頂部。這符合everyotherexample我可以在Infragistics網站上找到。我可以將Ignite UI腳本放在頁面底部嗎?

我想加載這些文件在頁面的底部,而不是。然而,當我嘗試這樣做,我得到一個JavaScript錯誤:

ReferenceError: $ is not defined 

在視圖,我用的是網格的HTML幫助像這樣(簡化):

@model IQueryable<Product> 

@(Html.Infragistics().Grid(Model).DataBind().Render()) 

這對產生以下輸出頁:

<table id="Grid1"></table> 
<script type="text/javascript">$(function() {$('#Grid1').igGrid({ ... });</script> 

如果我能告訴的Infragistics把script標籤頁面的底部,我加載了jQuery,jQuery UI的,等以後,一切都將是桃色的。有沒有辦法可以做到這一點,仍然使用HTML助手?

回答

0

您可以使用Infragistics Loader查閱JavaScript資源。

在CSHTML你將有:

<script src="Scripts/infragistics.loader.js" type="text/javascript"></script> 

而在另一個腳本標籤,您將具備以下條件:

$.ig.loader({ 
scriptPath: '{IG Resources root}/js/', 
cssPath: '{IG Resources root}/css/'}); 

$.ig.loader('igGrid.Paging.Updating', 
    function() { 
    // Create a couple of igGrids 
     $("#grid1").igGrid({ 
     virtualization: false, 
     autoGenerateColumns: true, 
     jQueryTemplating: false, 
    // and other} 

瞭解更多關於此這裏:http://help.infragistics.com/Help/Doc/jQuery/2013.1/CLR4.0/html/Deployment_Guide_JavaScript_Resources.html#referencing_resources

+0

這是假設,我會不是使用HTML助手,對吧? – 2014-10-29 16:30:38