I am trying to write some javascript that creates HTML controls based on feedback from a SharePoint WebServices getList. I store the control in an array after the creation of the array, until it does not execute a warning, then it becomes the correct number.
var controls = []; Call the webserver ($ {Operation: "GetList", list name: qs ["list"], fullfunk: parselists to retrieve $ [document] .ready (function () {// list data $ ()). }; Console .log (controls.length); // This output 0 warnings ("It is here to work."); // it should be here; why not console.log (controls.length); // for output 6 (var i = 0; i & lt; controls.length; i ++) {control [i] .addControl ();}}); Function Parslink (ExData, Status) {$ (xData.responseXML) .Find ("Field"). Each (function () {if ($ (this) .attr ("ID") & $ (this) Attr ("SourceID") = "http://schemas.microsoft.com/sharepoint/v3") { If ($ (this) .attr ("type") == "text") {controls.push (new textbox (it));} and if ($ (this) .attr ("type") == "option "& Amp; amp; $ (this) .attr (" format ") ==" dropdown ") {control push (new dropdown (this)); and if ($ (this) .attr (" type ") == "Option" & amp; $ (this) .attr ("Format") == "Radiobutton") {Control.push (New Radiobutton (this)); and if ($ (this) .attr ("Type" ) == "multichoice") {controls.push (new multi-option (this));} and if ($ (this) .attr ("type") == "Boolean") {controls.push (new boolean (this));}}}); } Alert is the only thing that works with controls.length . I can only think that this is some type of problem. No insights is appreciated.
This is probably due to this asynchronous code
$ () . SPServices ({Operation: "GetList", list name: qs ["list"], fullproduct parselists}); Warning prevents thread execution temporarily for allow callback function
Then try to move this part
console.log (controls.length); // for output 6 (var I = 0; i & lt; controls.length; i ++) {control [i] .addControl (); } parseList () function in
Comments
Post a Comment