jQuery lavaLamp,对孩子行为不端
您可以在此处查看该问题的实时示例:http://www.welasewodewick.com/redesign2 - 将鼠标悬停在“博客”li 上,然后悬停在弹出的子菜单上。
我不会发布插件的完整源代码,因为它相当冗长,但您应该能够直接在此处查看它们:
lavaLamp jQuery 插件
http://www.welasewodewick.com/redesign2/includes/jquery。 lavalamp.js
菜单标记
<nav>
<article>
<ul>
<li><a href="#Home" alt="#">Root</a></li>
<li><a href="#About" alt="#">Who?</a></li>
<li><a href="#Projects" alt="#">Projects</a></li>
<li><a href="#Resume" alt="#">Blog</a>
<ul class='children'>
<li class="page_item page-item-18"><a href="http://localhost/wordpress/?page_id=18" title="History">History</a></li>
<li class="page_item page-item-13"><a href="http://localhost/wordpress/?page_id=13" title="Our Company">Our Company</a></li>
<li class="page_item page-item-15"><a href="http://localhost/wordpress/?page_id=15" title="Our Staff">Our Staff</a></li>
</ul>
</li>
<li><a href="#Resume" alt="#">Contact</a></li>
</ul>
</article>
</nav>
lavaLamp 激活
$(function() { $('nav>article>ul').lavaLamp(); });
非常感谢您对此问题的意见:)
** 目的 ** 该模型的最终落脚点是 WordPress 模板,因此菜单的嵌套结构大多需要保持不变。
非常感谢 狐狸精
I've been playing around with http://nixboxdesigns.com/projects/jquery-lavalamp/ for a navigation menu on a new site I'm building and it works great with minimal fuss, I then started wondering if I could add some sub navigation options to the menu and set about building that in. The trouble I'm having is making the lavaLamp plugin ignore nested/child ul/li's.
You can see a live example of the issue here: http://www.weleasewodewick.com/redesign2 - hover over the 'Blog' li then over the submenu that pops in.
I won't post the full source for the plugins as it's pretty lengthy but you should be able to view them directly here:
lavaLamp jQuery Plugin
http://www.weleasewodewick.com/redesign2/includes/jquery.lavalamp.js
Menu Markup
<nav>
<article>
<ul>
<li><a href="#Home" alt="#">Root</a></li>
<li><a href="#About" alt="#">Who?</a></li>
<li><a href="#Projects" alt="#">Projects</a></li>
<li><a href="#Resume" alt="#">Blog</a>
<ul class='children'>
<li class="page_item page-item-18"><a href="http://localhost/wordpress/?page_id=18" title="History">History</a></li>
<li class="page_item page-item-13"><a href="http://localhost/wordpress/?page_id=13" title="Our Company">Our Company</a></li>
<li class="page_item page-item-15"><a href="http://localhost/wordpress/?page_id=15" title="Our Staff">Our Staff</a></li>
</ul>
</li>
<li><a href="#Resume" alt="#">Contact</a></li>
</ul>
</article>
</nav>
lavaLamp Activation
$(function() { $('nav>article>ul').lavaLamp(); });
Would really appreciate your input on this issue :)
** Purpose **
The final resting place of this mockup is a WordPress template, so the nested structure of the menu mostly needs to remain the same.
Much appreciated
Foxed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
呵呵,我终于成功了:)
这是演示:http://jsbin.com/uyali3< /strong>
使用
作为子节点很难完成这个任务,所以我将其改为
去查看代码你自己 =)
注意:下次您发布问题时,请务必提供正确的代码/HTML。我花了大约
45 分钟
来理解您的整个代码。最后我找到了解决您问题的方法 =)代码:
huh, finally I got it work :)
here's the Demo : http://jsbin.com/uyali3
It is difficult to achieve this task using
<ul>
as child node, so I changed it to<div>
go check out the code yourself =)
NOTE : Next time when you post a question please be sure, to provide the proper code/HTML. I took me around
45 min
to understand your entire code. At last I found a fix to your problem =)Code :
我也有同样的问题,但我不想修改 WordPress 模板:
首先,我考虑将类“noLava”添加到每个深度 > 的
中。 1,所以我尝试用自定义类来扩展 Walker 类 - 但没有成功。
然后我开始修改lavalamp jquery插件,经过一整天的尝试,我找到了解决方案 这里,所以我将其修改如下,它就像一个魅力:)
也许最好的解决方案是保留原始行为并添加这个。
编辑:[在线演示]
I had the same question too, but I didn't want to modify wordpress templates:
Firstly I thought about adding the class "noLava" to every
<li>
with depth > 1, so I tried to expand the Walker class with a custom one - with no success.Then I started to modify the lavalamp jquery plugin, and after having tried all day long I found the solution here, so I modified it as below, and it works like a charm :)
Maybe the best solution is to preserve the original behavior and add this one.
Edit: [online demo]
我分叉了 LavaLamp 插件,并添加了“hoverTarget”选项。
它使用“目标”元素内的元素进行悬停检测。
(默认值:“a”)
这修复了子列表的问题。
在这里获取它:GitHub
I forked the LavaLamp plugin, and added a "hoverTarget" option.
It uses an element inside the "target" element for the hover detection.
(default: "a")
This fixes the issues with child lists.
get it here: GitHub