2016-04-07 2 views
0

私はSharePoint 2013用のイメージスクロールを構築していますが、このエラーをこの行に指摘しています。私はhtml/jsを学んでいますので、私はすべての助けに感謝します。ReferenceError:ウェブサイトが定義されていません

このコードの行が

var oList = website.get_lists().getByTitle(bannerListName);  

エラーを返してあり、それよりはあるが、それを止めるいただきました!これはあります。

(function() 
{ 
/********************* User Defined Variables *************************************** 
**** Update the variables below to customize how the banner rotator works ***********/ 
var bannerListName = "Banner Rotator"; //the name of the list to pull the banner items from 
var interval = 7; //time to wait before showing the next picture (in seconds) 
var showPages = false; //change to false if you do not want to show the page numbers 

//if you know how to write CAML you can update this string 
//by default it looks for all items in the list, but you can change that here 
var query = '<View><Query><Where><Geq><FieldRef Name=\'ID\'/><Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>'; 
/***********************************************************************************/ 

//global variables 
var index = 0; 
var bannerList = []; 

$(document).ready(function() 
{ 
     // make sure the SharePoint script file 'sp.js' is loaded before code runs 
     SP.SOD.executeFunc('sp.js', 'SP.ClientContext',start); 
         }); 

function start() 
{ 
    ctx = SP.ClientContext.get_current(); 
    this.site = ctx.get_site(); 
    this.website = ctx.get_web(); 
    var oList = website.get_lists().getByTitle(bannerListName); 
    var camlQuery = new SP.CamlQuery(); 
    camlQuery.set_viewXml(query); 
    this.collListItem = oList.getItems(camlQuery); 
    ctx.load(collListItem); 
    this.ctx.executeQueryAsync(onQuerySucceeded, onQueryFailed); 

} 

答えて

1

それはthis.websiteする必要がありますだけでなく、website

this.website = ctx.get_web(); //<-- you store it in this.website, not var website 
var oList = this.website.get_lists().getByTitle(bannerListName); 
+0

また、時々私は、単に再利用のために同じ名前の変数を作成したいです。 'var website = this.website = ctx.get_web();'というように、後で同じ文脈で 'website'も使うことができます。 –

+0

これは私の質問に答えた:)しかし、私のエラーをもたらした。私は何が起こっているのか理解したので、これらを試して作業します!ありがとうございました – user6174153

関連する問題