0

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;
 }
1

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.

  • Thank you, then this solution does not suit me, thank you. – Fox May 31 at 14:09

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.