标签: riot

Riot.js - 访问标记元素的上下文以隐藏/显示该元素

<tooltip message="Click Tooltip" content="Click tooltip preview"></tooltip>
    <tooltip message="Click Tooltip 1" class="repeat-tooltip" content="Click tooltip 1 preview"></tooltip>
    <tooltip trigger="hover" class="repeat-tooltip" message="Hover Tooltip" content="Hover tooltip preview"></tooltip>
Run Code Online (Sandbox Code Playgroud)

Riot.js尝试创建自定义工具提示标记的新手,一次只能激活一个工具提示.

   <tooltip>
       <p class="tooltip-content" control="tooltip">{ message } ref="target"</p>
       <div class="tooltip-wrapper" show={show_message} ref="content">
          //inner html
       </div>
   </tooltip>
Run Code Online (Sandbox Code Playgroud)

尝试使用show toggling show_message值来显示和隐藏工具提示.但是show_message是在特定元素click事件的上下文中.单击特定工具提示,如果该工具提示已经打开,如何访问其他自定义标记的上下文以隐藏该特定元素的值?

   this.root.addEventListener('click', (e) => that.toggle_message(e));

   this.toggle_message = function(e) {
        //here close all other tooltips before opening this one. How can I access the refs of all the open tooltip?

        this.show_message = !this.show_message;
        this.update();
    };
Run Code Online (Sandbox Code Playgroud)

提前致谢.

javascript tooltip custom-tags riot riotjs

8
推荐指数
1
解决办法
328
查看次数

是否可以将Javascript代码与Riot Js中的标记文件分开?

我想知道是否可以这样做:

<todo>
    <div class="greetings">Hello, world!</div>

    <script src="/path/to/my/file.js"></script>
</todo>
Run Code Online (Sandbox Code Playgroud)

当js代码保留在不同的文件中时,标记将保留视图(html):

  • todo.tag(html/css)
  • todo.js

javascript riot.js riot

4
推荐指数
1
解决办法
1491
查看次数

标签 统计

javascript ×2

riot ×2

custom-tags ×1

riot.js ×1

riotjs ×1

tooltip ×1