Need help with plugin making and java script!

Hi everyone!

I am trying to make a simple plugin as a way to put into practice what I’m currently learning in JavaScript!
my plugin is just provide an element (I called it text+button) that display a text with inline “Read more” button (like in facebook posts), I’m almost finished making this element but the final problem I’m facing is that when you put more than one “text+button” element the first element will work properly put the others if there button clicked they will not work but affect the first element.

I built this feature in the past for a social media site using a HTML element (although I wasn’t familiar with coding) by copying a code from the internet and modifying it in a funny way to make it work. but now I want to improve my coding skills for nocode purposes.

Regarding my plugin the codes I write are this:
For initialize function:

function(instance, context) {
  const div = instance.canvas[0];

  const visibleText = document.createElement("p"); = "inline";

  const dots = document.createElement("p"); = "inline";

  const moreText = document.createElement("p"); = "none";

  const butn = document.createElement("button"); = "inline";    

for update function:

function(instance, properties, context) {
  const div = instance.canvas[0];
  const visibleText = div.getElementsByTagName("p")[0];
    visibleText.textContent = properties.text.slice(0, properties.text_length);
  const dots = div.getElementsByTagName("p")[1];
    dots.textContent = "... "; = "dots";
  const moreText = div.getElementsByTagName("p")[2];
    moreText.textContent = properties.text.slice(properties.text_length) + " "; = "more";
  const butn = div.getElementsByTagName("button")[0];
    butn.textContent = properties.button_name_when_collapsed; = "myBtn";
    butn.onclick = myFunction; = properties.btn_backgroun_color1; = properties.btn_name_color1;
    let btnfontsize = properties.btn_name_size1 + "px"; = btnfontsize;
    if (properties.button_with_border == true) { = "1px solid #000";
    else { = "none";
  if (properties.text.length <= properties.text_length) { = "none"; = "none";

  function myFunction() {
      const dots = document.getElementById("dots");
      const moreText = document.getElementById("more");
      const btnText = document.getElementById("myBtn");
      if ( === "none") {
 = "inline";
          btnText.innerHTML = properties.button_name_when_collapsed;
 = "none";         
      else {
 = "none";
          btnText.innerHTML = properties.button_name_when_expanded;
 = "inline";

I hope some one can help me understand this problem and found a solutin

Coming from someone who was writing plugin code this morning: Why make a plugin for this, just wondering. What you’re describing would be easier using bubbles nocode expression builder, groups, and conditionals.

1 Like

My first goal of building this plugin is to improve my coding skills for nocode purposes, so for this goal I need to understand what is the problem in my code.

On the other hand, I didn’t understand what the “expression builder” is, and I dont know a nocode way to do this, I would be glad and grateful if you would explain this way. My be if it is an advanced way, it would be reasonable to build a tool that simplifies it!

where is the best place to get an answer for this question?