我在下面的代码中显示了一个小型JS应用程序。它在SharePoint Online中运行并连接到短列表以在红色,黄色或绿色“状态”之间循环。我不知道要改变什么才能使它与第二个应用程序保持“分离”,完全相同但具有不同的标题/含义。目前,我创建了第二个名称不同的列表,并将URL行更改为指向该列表,但Web部件显示为黑色,如下所示。
<div id="production-planning-btnPopover" class="pp-container" style="cursor:pointer;" data-toggle="popover" title="Popover Header" data-content="This content gets replaced" data-placement="bottom">Production Planning Status<i class="ms-Icon ms-Icon--Info" id="pp-status-icon"></i></div>
<script>
(function(){
var call = $.ajax({
url: "https://MYCOMPANY.sharepoint.com/_api/Web/Lists/GetByTitle('Production%20Planning')/items?$select=Status&$filter=Title%20eq%20\'Current%20Status\'",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
});
call.done(function (data,textStatus, jqXHR){
var ppStatus = data.d.results[0].Status;
if(ppStatus == "Green"){
$("#production-planning-btnPopover").addClass("pp-green");
$("#production-planning-btnPopover").click(function(){
$(".popover-title").text("Milwaukee DC On Schedule for On-Time Completion");
$(".popover-content").text("Enter orders as normal.");
});
} else if(ppStatus == "Yellow"){
$("#production-planning-btnPopover").addClass("pp-yellow");
$("#production-planning-btnPopover").click(function(){
$(".popover-title").text("DC Near Capacity");
$(".popover-content").text("Continue to enter orders as normal however if you have an order larger than 10,000 in quantity contact the Milwaukee OCN so the DC can provide you with realistic ship dates based on your customer's demand.");
});
} else {
$("#production-planning-btnPopover").addClass("pp-red");
$("#production-planning-btnPopover").click(function(){
$(".popover-title").text("DC At Capacity");
$(".popover-content").text("DC is currently at or beyond capacity. Try to schedule orders at other DC locations. If you cannot, contact OCN so the DC can provide you with realistic ship dates based on your customer's demand.");
});
}
});
call.fail(function (jqXHR,textStatus,errorThrown){
alert("Error retrieving list data: " + jqXHR.responseText);
});
})();
$('body').on('click', function (e) {
//did not click a popover toggle or popover
if ($(e.target).data('toggle') !== 'popover'
&& $(e.target).parents('.popover.in').length === 0) {
$('[data-toggle="popover"]').popover('hide');
}
});
$(document).ready(function(){
$('[data-toggle="popover"]').popover();
});</script>
答案 0 :(得分:0)
你是什么意思'保持'与第二个应用程序分开?
在SharePoint托管的加载项中,我们可以创建两个客户端Web部件来单独显示内容。
如果应用中的列表,我们需要使用下面的代码来获取appweburl。
appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl"));
有关使用REST API创建SharePoint托管加载项的更多信息供您参考: http://www.c-sharpcorner.com/UploadFile/58e23e/sharepoint-hosted-app-using-rest-api-from-client-side-script/