-2

What is the alternative of innerHtml in riotjs like

asdfghjkl

in js we write var str=document.getElementById("one").innerHtml; but for the same html tag we have to get that value in riotjs

like riot.id will return value "one" what function will retun value "asdfghjkl" instead of .

Ahmed Raza
  • 89
  • 1
  • 7

1 Answers1

0

If I understand your question correctly you would like to get the innerHTML of your created tag. That is as easy as "this.root.innerHTML".

<riot-tag>
   asdfghjkl
   <script>
      this.on('updated', function(){
         console.log(this.getInnerHTML());
      });
      getInnerHTML(){
         return this.root.innerHTML;
      }
   </script>
</riot-tag>

If you need the innerHTML of any sub-element of your created tag set a name or id property on the element and reference it directly. Or if you are calling your function from an event, like click, have the element reference from e.target.

<riot-tag>
   <h1 onclick={getInnerHTML} name="myTagHeader">asdfghjkl</h1>
   <script>
      getInnerHTML(e){
         console.log(e.target.innerHTML);
         console.log(this.myTagHeader.innerHTML);
      }
   </script>
</riot-tag>

Hope that it will help

P-H
  • 43
  • 8
  • Sorry Both of these solutions are not applicable. Riot uses the class "opts" and i need that perticuler function of this class that is used to access the inner text of any tag. – Ahmed Raza Sep 27 '15 at 11:25
  • Would you like a property on opts to hold the innerhtml of your element? – P-H Sep 28 '15 at 18:20