javascript - ember.js 小部件

标签 javascript widget ember.js

我知道 ember js 适用于单页应用程序,而且您似乎可以将 ember js 应用程序本地化到单个 dom 容器而不是整个页面,所以我想知道 ember js 是否适合高级应用程序小部件的创建,不仅仅是一个稍微花哨的下拉菜单或任何东西,而是一个更复杂的小部件,它可以处理自己的 restful 资源等。或者以这种方式使用 ember.js 是不是有点矫枉过正?

如果它适用于小部件,当 ember 应用程序来自不同的作者时,是否有可能无需重新编码小部件以在同一页面上使用多个 ember 小部件应用程序,我的意思是我可以的一个例子在同一页面上轻松拥有来自不同来源的多个 jquery 插件,而不会发生任何冲突。

最佳答案

Ember.js 对于复杂的小部件来说并不过分,而且完全可以在一个页面上使用多个 ember 小部件应用程序。但是,需要对代码进行一些修改。来自Ember.js code :

"By default, Ember.Application will begin listening for events on the document. If your application is embedded inside a page, instead of controlling the entire document, you can specify which DOM element to attach to by setting the rootElement property:

    MyApp = Ember.Application.create({
      rootElement: $('#my-app')
    });

The root of an Ember.Application must not be removed during the course of the page's lifetime. If you have only a single conceptual application for the entire page, and are not embedding any third-party Ember applications in your page, use the default document root for your application.

You only need to specify the root if your page contains multiple instances of Ember.Application."

现在明显的问题是如何在加载 JavaScript 之前为每个小部件设置 rootElement。我可以想到多种方法来做到这一点,但最好的方法取决于您尝试做的任何设置。希望这能让您走上正确的道路。

关于javascript - ember.js 小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8509076/

相关文章:

javascript - 图像 map 浏览器兼容性和 imagemapster

android - 从 Widget 启动 Activity 首先会阻止应用程序启动相同的 Activity

android - 是否可以在锁定屏幕上创建类似 Google Play 音乐的小部件?

ember.js - Uncaught Error : Assertion Failed: calling set on destroyed object

ember.js - 为什么 "Assertion failed: You can only add a '故事“这段关系的记录”被抛出?

javascript - 图像悬停同时显示所有图像

javascript - div 中的自动滑动内容?

javascript - 如何使用 PhantomJS 渲染完整图表?

Facebook 按钮在 Firefox 和 Chrome 上呈现不同

ember.js - 创建路径助手,将哈希传递给 Handlebars 助手或连接字符串