emberjs和foundation4

我正在尝试使用现在使用zepto框架的emberjs和foundation 4,但是只要我将emberjs include添加到我的application.js中,基础代码就会停止工作。 包含的顺序有问题吗?

//= require jquery //= require jquery-ui //= require jquery_ujs //= require events //= require foundation //= require rails.validations //= require rails //= require gmaps4rails/gmaps4rails.base //= require gmaps4rails/gmaps4rails.googlemaps //= require handlebars //= require ember //= require ember-data //= require teammngt //= require_self TeamMngt = Ember.Application.create(); $(document).foundation(); 

TL; DR

 TeamMngt = Ember.Application.create({ ready: function() { Ember.run.next(this, function(){ $(document).foundation(); }); } }); 

要么

创建应用程序后添加:

 TeamMngt.ApplicationView = Ember.View.extend({ didInsertElement: function() { Ember.run.next(this, function(){ $(document).foundation(); }) } }); 

注意:将 TeamMngt更改为您设置的任何内容= Ember.Application.create();


一些说明:

加载应用程序模板后,会触发didInsertElement事件。 但是将$(document).foundation()单独$(document).foundation()那里是行不通的(我猜测事物的加载/绑定方式或其他)。 所以我做了:

 didInsertElement: function() { setTimeout(function() { $(document).foundation(); }, 0); } 

有一个0ms的setTimeout()似乎很奇怪,所以我认为有一个更好的方法。 因此,导致将$(document).foundation()放入Ember.run.next()


致谢: Zaxnyd
参考: Ember.js Ember.View didRender事件