yairEO/tagify

Help with "tagData"

Aperta

#1018 aperta il 22 apr 2022

 (10 commenti) (0 reazioni) (0 assegnatari)HTML (456 fork)github user discovery
Help wanted

Metriche repository

Star
 (3880 stelle)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Prerequisites

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Hello guys!

I'm giving Tagify a little strange use. In a form, to add new students, there is a field where some observations can be entered by the operator.

With the code below, I make the observations to be entered with the current date and the operator name.

cObs.getDispElem().tagify ({
  duplicates : true,
  maxTags : Infinity,
  delimiters : "\n|\r",
  transformTag : transformTag, 
  placeholder : "Observation...",
  editTags : true,
  pasteAsTags : true,
  backspace : false
});

// Generate colors
function getRandomColor() {
  function rand(min, max) {
    return min + Math.random() * (max - min);
  }

  var h = rand(1, 360) | 0,
  s = rand(40, 70) | 0,
  l = rand(65, 72) | 0;

  return 'hsl(' + h + ',' + s + '%,' + l + '%)';
}

function transformTag(tagData) {
  tagData.color = getRandomColor();
  tagData.style = "--tag-bg:" + tagData.color;
  tagData.value = proxy.CurrDate + " | " + proxy.CurrUser + ": " + tagData.value; //CurrDate & CurrUser are PHP sessions 
}

It's working perfectly.

image

The problem is when I go back to the registry to edit it. In this case, all observations are updated with the same date and the same operator name.

image

How could I get around this problem? I'm using it in jquery mode within PHPRunner.

Thanks!

Guida contributor