Closed netsuper closed 8 years ago
Can you post your code?
var selected = $("input[name='user']").pickSPUser("method", "getSelected");
alert("There are " + selected.length + " people selected!");
<div class="pt-pickSPUser">
<div class="pt-pickSPUser-selected">
None Selected!
</div>
<div style="clear:both"></div>
<div class="pt-pickSPUser-input"
title="Type user name above to view search results.">
<input name="users" value="" type="text"/>
</div>
</div>
<div class="pt-pickSPUser-person">
<div class="pt-pickSPUser-person-cntr ui-state-default ui-corner-all">
<span class="pt-person-name"></span>
<div class="pt-pickSPUser-person-actions">
<div class="tt-record-item-action-links">
<a class="tt-delete-icon" href="javascript:">
<img style="border: medium none; margin-right: 2px;" alt="Delete" src="/_layouts/images/delitem.gif">
</a>
<div style="clear:both;"></div>
</div>
<div style="clear:both;"></div>
</div>
</div>
</div>
$("input[name='users']").pickSPUser({ webURL: siteURL, inputPlaceholder: 'Search and add...', allowMultiples: true });
I'm actually trying to get the list so that I can save it in SOAP. That's possible, correct?
your setup looks ok. I assume that you did not actually insert the HTML markup you posted above and that was just to show that it was initialized correctly, right?
Can you also post your code on how you are retrieving the value?
Just so I understand, are these the steps you are doing:
getSelected
and don't see anything... is that right?
Can you try this to see what might be going on:
console.log( "user input count: " + $("input[name='user']").length )
On the same line where you have your call to getSelected
, can you also check the value of the input:
console.log( "input vlaue: " + $("input[name='user']").val() )
Yes, that is possible... The input field will actually have the list of users selected as a string in the same format that can be used on List updates.
var itemstring = thisyear + '|' + $("#newItemObjective").val() + '|' + $("#newItemTitle").val() + '|' + $("#newProduct").val() + '|' + $("#newItemDescription").val() + '|' + $("#newPOCORG").val() + '|' + $("#newPOC").val() + '|' + $("#newDueDate").val() + '|' + $("#newRebaseline").val() + '|' + $("#statusselect").val() + '|' + "0"; CreateNewItem($("#actionid").text(),itemstring); $("input[name='users']").pickSPUser("method", "clear" );
I'm sorry... but I'm not sure what I am looking at... nothing that you pasted above includes getting the value from the people picker widget... The only thing that stands out is that you are clearing the input[name='users']
at the end of that code snippet.
(ps please format your blocks of code using 3 backticks (`)... if you use only one, it does it inline only and looses new line breaks.)
Thanks for this code, it's great and very helpful! When using the example code, I get no data returned on the getSelected() method. I thought I might have the wrong element selected (based on the fact that the JS injects new code into the DOM), but it seems correct? Any ideas? Scott