I have created a Form on SharePoint using SPD, where I have used SharePoint PeoplePicker to get the User automatically.
Below is the code:-
$(document).ready(function () {
// Specify the unique ID of the DOM element where the
// picker will render.
initializePeoplePicker('temp');
//How can I use class here.
//initializePeoplePicker('classnamehere')
});
// Render and initialize the client-side People Picker.
function initializePeoplePicker(peoplePickerElementId) {
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = false;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '180px';
// Render and initialize the picker.
// Pass the ID of the DOM element that contains the picker, an array of initial
// PickerEntity objects to set the picker value, and a schema that defines
// picker properties.
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
$("temp_TopSpan").removeAttr("style").attr("style","width:180px");
}
The above code works fine for the unique Id.
How can I run this function for a class instead if ID. Because I am Adding new rows in the table dynamically and each new row with 2nd column should have peoplepicker div.
initializePeoplePicker('temp' + newRowCount);
where newRowCount is the index of the row, which bought peoplepicker in the new row. – BBRK Nov 8 '18 at 8:05