使用jQuery为客户端人员选择器设置多个电子邮件

时间:2016-01-05 09:05:48

标签: jquery sharepoint-online

我使用以下代码为我的客户选择者设置了一个电子邮件地址:

var userName = "addressA@in.com";    
var ppDiv = $(searchTab).find("div[title='Enter names or email addresses...']");                
var ppEditor = ppDiv.find("input[title='Enter names or email addresses...']");              
var spPP = SPClientPeoplePicker.SPClientPeoplePickerDict[ppDiv.attr('id')];             
ppEditor.val(userName);
spPP.AddUnresolvedUserFromEditor(true);

但是,我想在这里为人们选择器设置多个电子邮件地址。例如,

var userName = "addressA@in.com; addressB@in.com"

1 个答案:

答案 0 :(得分:0)

使用另一个userName调用相同的方法已经成功了。

var userName = "addressA@in.com; addressB@in.com"
var splitNames = userName.split(';');
for(var i=0;i<splitNames.length;i++){
    var ppDiv = $(searchTab).find("div[title='Enter names or email addresses...']");                
    var ppEditor = ppDiv.find("input[title='Enter names or email addresses...']");              
    var spPP = SPClientPeoplePicker.SPClientPeoplePickerDict[ppDiv.attr('id')];             
    ppEditor.val(splitNames[i]);
    spPP.AddUnresolvedUserFromEditor(true);
}

希望这有帮助。