没有框架的 JavaScript 树功能
我想使用 JavaScript 在 Facebook 页面上显示一棵树。 因此,不能依赖于 jQuery 或 Ext 等框架。没有在 Facebook 上运行,至少据我所知,我上次在该平台上工作是在 2009 年 4 月。 有人可以推荐一个“无框架”的 JavaScript/tree 库吗? 我已经将一些相当复杂的 JavaScript 移植到 Facebook,因此我确信我能够移植几乎任何现有的纯 JavaScript 库。
澄清点:
- 我的目标是 FBJS
- 我也可以(并且确实)谷歌搜索 JavaScript/树引擎,但正在寻求关于哪些引擎的建议
I'd like to display a tree on a Facebook page with JavaScript. Therefore there can be no dependencies on frameworks such as jQuery or Ext which won't run on Facebook, at least as far as I know when I last worked on that platform (April 2009). Can anybody recommend a "framework-free" JavaScript/tree library? I have ported some fairly complex JavaScript to Facebook so I'm sure I'll be able to port just about any existing pure JavaScript library.
Clarification points:
- I am targeting FBJS
- I too can (and did) google for JavaScript/tree engines but am seeking recommendations as to which one(s)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
看看这个实现... http://www.destroydrop.com/javascripts/tree/
Look at this implementation... http://www.destroydrop.com/javascripts/tree/
你没有描述你的 JS 树的要求,所以我建议你自己写一个。 这是一个相对简单的任务,除非您需要更复杂的功能。
一棵简单的树只是拥有一堆 DOM 节点,这些 DOM 节点内部还有其他可以打开和关闭的 DOM 节点(显示块/无)
You didn't describe the requirements for your JS tree, so I would suggest you write one yourself. It's a relatively simple task unless you need more complex functionality.
A simple tree is just a matter of having a bunch of DOM nodes that have other DOM nodes inside them that can be toggled on and off (display block/none)
即使您主要使用 FBML 和 FBJS,您也可以使用
来渲染原始 HTML 和 JavaScript,而无需进行 FB 修改。您的目标是什么类型的页面?
适用于画布页面,但不适用于用户的个人资料页面。Even if you work mostly in FBML and FBJS, you can use
<fb:iframe/>
to render raw HTML and JavaScript without the FB munging going on.What kind of page are you targeting?
<fb:iframe/>
works on canvas pages but not on a user's profile page.我查看了 FBJS 中的修改。 不知道为什么它会让 jQuery 不起作用,但如果有人有一些见解,我很想听听。
我确实知道由于冲突你可能无法使用 jQuery 的 $ 。 但这可以很容易地从 $() 更改为 jQuery() 。
我可以告诉你我喜欢什么树视图,但如果不在 Facebook 中尝试,它可能会因为与 jQuery 相同的原因而失败。
I looked at the munging in FBJS. Not sure why it would make jQuery not work, but if someone has some insight, I'd love to hear it.
I do know that you probably can't use jQuery's $ due to conflicts. But that can be changed from $() to jQuery() easily enough.
I could tell you what treeview I like, but without trying it in Facebook it might fail for the same reasons as jQuery.
你真的应该编写并测试你自己的,以获得你想要的东西,并且你没有准确地描述你想要从树中得到什么,但也许你可以尝试免费版本的 树视图。
You really should write and test your own to get exactly what you want, and you didn't describe exactly what you want from a tree, but perhaps you could try the free version of treeview.
我使用过 http://sortablejs.github.io/Sortable/#nested巨大的成功。 默认用户界面可能会让您感到困惑(它看起来不像树),但当您考虑移动用户时,这种外观实际上效果更好。
I've used http://sortablejs.github.io/Sortable/#nested with great success. The default UI might throw you off (it doesn't look like a tree) but when you consider mobile users this look actually works much better.