New Item, Custom Form, Call Out(?)
-
04-10-2020 - |
質問
In my webpart when I click new item I get:
Is there a way to make this box appear to create a new list item when I link a link?
I want to have something hyperlinked like "Send Feedback" that people can click and get a callout box like this.
Let me know how to communicate my question better, Thankyou.
解決
Use the SP.UI.ModalDialog.showModalDialog
function to open a dialog like this:
function openURL(){
SP.UI.ModalDialog.showModalDialog({
url: "pageurl.aspx",
title: "Feedback",
allowMaximize: true,
showClose: true,
width: 800,
height: 600,
dialogReturnValueCallback: newCallback
});
function newCallback(dialogResult, returnValue) {
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
}
Update
You can use this function like
<button onclick="javascript:return openURL();">Feedback</button>
You can add a javascript file using the content web part.
Edit page -> Add web part -> Media and content -> Content editor -> Add
Edit the source of the web part and add the following code into it:
<script src="/sites/subsite/list/SiteAssets/file.js" type="text/javascript"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
Add the js file under Site Assets using SharePoint Designer.