yairEO/tagify

Help with "tagData"

Aberta

#1.018 aberto em 22 de abr. de 2022

 (10 comentários) (0 reação) (0 responsável)HTML (456 forks)github user discovery
Help wanted

Métricas do repositório

Stars
 (3.880 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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!

Guia do colaborador