With a button on page which calls the function createListItems()
which is added to the page as a link in a CEWP. The function takes 10-25 seconds to complete (get items from one list and add them to another). The only indication that something is happening is that the button remains 'pushed' until the script completes.
Where do I add SP.UI.ModalDialog.showWaitScreenWithNoClose
so that the modal appears when the function executes and closes when complete? I have added it to this script in the obvious places but only get the waitScreen at the end for a millisecond.
Here is my current code:
<script type="text/javascript" src="/SiteAssets/jQuery/jquery.min.js"></script>
<script type="text/javascript" src="/SiteAssets/jQuery/jquery.SPServices-0.7.2.min.js"></script>
<script type="text/javascript">
function createListItems()
{
$().SPServices({
operation: "GetListItems",
async: false,
listName: "SourceList",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var name = ($(this).attr("ows_Title"));
CreateNewItem(name);
});
}
});
}
function CreateNewItem(name) {
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: "ReceiveList",
valuepairs: [["Title", name],
completefunc: function(xData, Status){
""
}
});
//Refreshes page to show new items in 'ReceiveList' list view web part
window.location = window.location.pathname;
}