0

I want to show dialog when click tree-record, i used js to write code below, but odoo show error message like question title

notificationDialogPopup: function(data){
   if(data){
      const container = document.createElement('div');
      container.setAttribute("id","container");

      const title = document.createElement('h1');
      title.setAttribute("id", "title");
      title.innerText = "Title Testing";

      const content = document.createElement('p');
      content.setAttribute("id","content");
      content.innerText = "Content Testing";

      const date = document.createElement('h6');
      date.setAttribute("id","date");
      date.innerText = "11-11-1999";

      const author = document.createElement('h6');
      author.setAttribute("id","author");
      author.inertText = "Admin";

      const btnClose = document.createElement('button');
      btnClose.setAttribute("id","button");

      const style = document.createElement('style');
      style.innerHTML = "#notification-container {}"
            + "#title {color:red}"
            + "#content {color:blue}"
            + "#date {color:red}"
            + "#author {color:red}"
            + "#button {color:red}"

      document.container.appendChild(title);
      document.container.appendChild(content);
      document.container.appendChild(date);
      document.container.appendChild(author);
      document.container.appendChild(btnClose);
      document.head.appendChild(style);
      document.body.appendChild(container);
   }
}

});

i tried change position appendChild but not working

  • First, you should check which object causes the error. These are possible root cause: `document.container`, `document.head`, `document.body`. After identifying where the problem is, we will have more information on what and why this is happenning. – holydragon Jan 11 '23 at 03:36
  • I think that since the container element is not defined in the HTML, then appendChild of other elements to the container will not be possible. – WilliamVietnam Jan 11 '23 at 03:50
  • i tried appendChild elements to body instead of container element. And it worked – WilliamVietnam Jan 11 '23 at 03:51

0 Answers0