0

I'm doing some customize operations on a person field in one of the forms. I need to fire a function once the edit form "Person" field is loaded. i tried window.load() but that takes too much time as the person field gets loaded long before the full page is loaded.

Is there any SP/jQuery event that tells me a form is fully loaded(as in all fields are populated with the existing values)?

0

Try below code.

Inside document.ready()

var tempData = JSON.parse($('[id^="' + peoplepickerFieldInternalName + '"] input')[0].value);

                var tempHTMLValue = "";

                if (tempData.length > 0) {

                    for (var i = 0; i < tempData.length; i++) {

                        if (i === 0) {
                            tempHTMLValue = "<a class='ms-subtleLink' href='" + Your Site URL + "/_layouts/15/userdisp.aspx?ID=" + tempData[i].EntityData.SPUserID + "'>" + tempData[i].DisplayText + "</a>"
                        }

                        else {
                            tempHTMLValue = tempHTMLValue + ", <a class='ms-subtleLink' href='" + Your Site URL + "/_layouts/15/userdisp.aspx?ID=" + tempData[i].EntityData.SPUserID + "'>" + tempData[i].DisplayText + "</a>"
                        }
                    }
                }

                $('[id^="' + peoplepickerFieldInternalName + '"]').parent().prepend('<div style="display:block !important;">' + tempHTMLValue + '</div>');

                $('[id^="' + fieldInternalName + '"]').hide();
  • it is not working. the people picker gets resolved after DOM gets ready. which means at the time this code runs the people picker is not resolved yet. – Abdul Hameed Feb 23 '17 at 7:27
  • yes,but have you got value in "tempHTMLValue" variable in document.ready()? – Samir Khimani Feb 23 '17 at 7:30
  • tempdata itself is not getting initialised as` input[0]` is not defined at the time of document.ready. so if condition never evaluates to true. – Abdul Hameed Feb 23 '17 at 9:35
  • Then i think window.load() is better option. – Samir Khimani Feb 23 '17 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.