为多个元素实现单个饼形菜单? [英] Implementing a single pie menu for multiple elements?

查看:113
本文介绍了为多个元素实现单个饼形菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为以下多个元素实施此菜单: / p>

>



元素是在javascript中动态创建的。



我需要为每个元素重新创建html(这是我在做什么现在)。或者有更简单的方法为每个元素使用相同的html。



一个想法是当用户点击星形时注入html。



另一个想法是使用一些定位机制。

解决方案

,不需要为每个元素重新创建HTML。它可以在HTML中创建一次,然后你可以切换它的可见性和使用jQuery的位置。查看jQuery的.position()方法。它非常强大。



另外,当用户点击星标时,您可以通过javascript注入html,是的。无论你选择哪种方式,我只创建一次HTML,然后使用jQuery定位。



希望这有助于。


I'm implementing this menu for multiple elements like this:

The elements are created dynamically in javascript.

Do I need to recreate the html for each element ( this is how I'm doing it now ). Or is there an easier way to use the same html for each element.

One thought was to inject the html when the user clicks on the star.

The other thought was to use some positioning mechanism.

解决方案

To answer your first question, no you don't need to recreate the HTML for each element. It can be created once in HTML and then you can toggle its visibility and position it using jQuery. Check out jQuery's .position() method. It's extremely powerful.

As an alternative you can inject the html via javascript when the user clicks on the star, yes. Either way you choose, I would only create the HTML once and then position it using jQuery.

Hope this helps.

这篇关于为多个元素实现单个饼形菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆