Use below function to clear the people picker control values from page on client side.
Code:
Function clearPeoplePicker(pickerId) {
var toSpanKey = pickerId+"_TopSpan";
var peoplePicker = null;
// Get the people picker object from the page.
var ClientPickerDict = this.SPClientPeoplePicker.SPClientPeoplePickerDict;
// Get the people picker object from the page.
for (var propertyName in ClientPickerDict) {
if (propertyName == toSpanKey) {
peoplePicker = ClientPickerDict[propertyName];
break;
}
}
if (peoplePicker) {
var ResolvedUsersList = $(document.getElementById(peoplePicker.ResolvedListElementId)).find("span[class='sp-peoplepicker-userSpan']");
$(ResolvedUsersList).each(function (index) {
peoplePicker.DeleteProcessedUser(this);
});
}
}
Code:
Function clearPeoplePicker(pickerId) {
var toSpanKey = pickerId+"_TopSpan";
var peoplePicker = null;
// Get the people picker object from the page.
var ClientPickerDict = this.SPClientPeoplePicker.SPClientPeoplePickerDict;
// Get the people picker object from the page.
for (var propertyName in ClientPickerDict) {
if (propertyName == toSpanKey) {
peoplePicker = ClientPickerDict[propertyName];
break;
}
}
if (peoplePicker) {
var ResolvedUsersList = $(document.getElementById(peoplePicker.ResolvedListElementId)).find("span[class='sp-peoplepicker-userSpan']");
$(ResolvedUsersList).each(function (index) {
peoplePicker.DeleteProcessedUser(this);
});
}
}
This comment has been removed by the author.
ReplyDeleteThanks, it helped me!
ReplyDeletesuperb
ReplyDelete