简体   繁体   English

如何在emberjs中使用salvattore

[英]How to use salvattore in emberjs

I am trying to get salvattore to work in my embercli project. 我试图让Salvattore参与我的embercli项目。 Currently I've followed the example at salvattore.com and it sort of works but puts '3 .column.size-1of3' on the grid div rather than creating column divs in the grid. 目前,我已经在salvattore.com上遵循了该示例,并且可以进行一些工作,但是将'3 .column.size-1of3'放在网格div上,而不是在网格中创建列div。

example html 范例html

<div id="grid" data-columns="">  <!-- (inspector style) content: '3 .column.size-1of3';  -->
  <div>Item #1</div>
  <div>Item #2</div>
  <div>Item #3</div>
  <div>Item #20</div>
</div>

I think this is happening because Salvattore isn't being inited at the correct time so the DOM isn't ready for it. 我认为发生这种情况是因为Salvattore没有在正确的时间初始化,因此DOM还没有做好准备。 I've tried creating a view with a didInsertElement function but I don't know how to get the Salvattore namespace to rerun the grid function. 我尝试过使用didInsertElement函数创建视图,但是我不知道如何获取Salvattore命名空间来重新运行grid函数。 Currently I get the error with the code below. 目前,我收到以下代码的错误。

Build error: 生成错误:

ENOENT, no such file or directory '/Users/mikev/dev/derp-ember-app/tmp/tree_merger-tmp_dest_dir-YVY49mzP.tmp/salvattore.js'

index view: 索引视图:

import Ember from 'ember';
import salvattore from 'salvattore';

export default Ember.View.extend({
    didInsertElement: function(){
        salvattore.register_grid();
        salvattore.recreate_columns();
    }
});

Any insight to my problem would be greatly appreciated. 任何对我的问题的见解将不胜感激。 Thanks 谢谢

I'm not sure where you are placing it now in is the right spot, as that's not going to be application global. 我不确定您现在将其放置在正确的位置,因为这不会成为应用程序全局。 Try: 尝试:

app/views/application.js 应用/视图/的application.js

/* globals salvattore */
import Ember from 'ember';

export default Ember.View.extend({
  _myUiInit: function () {
    salvattore.register_grid();
    salvattore.recreate_columns();
  }.on('didInsertElement')
});

The import should look like: 导入应如下所示:

Brocfile.js Brocfile.js

app.import( 'vendor/salvattore/dist/salvattore.js' );

(and restart the ember server after) (并在之后重新启动ember服务器)

Note: the above is untested (I don't use salvattore) but I use the exact same approach with Foundation, just the init function content is different. 注意:以上内容未经测试(我不使用salvattore),但我对Foundation使用完全相同的方法,只是init函数的内容不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM