Domanda

Created an Element in the ECB menu with dynamic items, when you try to access an item by clicking, the entire array is traversed and the last item is substituted, help the clicker to display the value of the desired item?

enter image description here

F12:

enter image description here

Code:

var L_DocumentLibrary_Text = "Copy items";
strDisplayText = L_DocumentLibrary_Text;
var docLib = CASubM(m,strDisplayText,"","",400);
docLib.id = "id_L_DocumentLibrary_Text";
var Const_DocLibs_Array = ["item 1", "item 2", "item 3", "item 4"];
for(var i = 0; i < Const_DocLibs_Array.length; i++)
 {
  var L_Doc_Text = Const_DocLibs_Array[i];
  strDisplayText = L_Doc_Text;
  strAction = "console.log('" + strDisplayText + "');";
  strImagePath = ctx.imagesPath + "existingLocations.gif";
  menuOption = CAMOpt(docLib,strDisplayText,strAction,strImagePath);
  menuOption.id = "id_" + L_Doc_Text;
 }
È stato utile?

Soluzione

It seems that strAction doesn't get evaluated until the whole loop completes. So the easy way to do this would be to forget the loop and write four separate CAMOpt calls each with its own strAction.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top