尝试将jQuery插件包装为Ember组件

时间:2016-05-08 23:50:39

标签: jquery ember.js

我正在尝试将Hootsuite Grid插件包装为Ember组件:

@IBAction func shuffleURL() {
    let randomI = Int.random(0..<urls.count)
    videoView.loadHTMLString(urls[randomI], baseURL: nil)
}

当我import Ember from 'ember'; const { computed } = Ember; export default Ember.Component.extend({ elementId: 'grid', classNames: ['grid'], tagName: 'ul', didInsertElement() { var self = this; var options = { lanes: 5, direction: 'horizontal', itemSelector: 'li[data-w]', widthHeightRatio: 1, onChange(changedItems) { console.log(this); } }; var gridList = this.$().gridList(options); this.set('gridList', gridList); }, willDestroyElement() { this.get('gridList').stop(); } }); 时,我可以看到在父对象上正确设置了选项,但没有传递给内部gridList对象

Properties in Chrome expor

虽然这些值似乎传递给我正在玩的测试小提琴中的子对象:

https://jsfiddle.net/evmowy9k/

enter image description here

我做错了吗?

1 个答案:

答案 0 :(得分:0)

Ember.run.next(this, function() {
    var gridList = this.$().gridList(options);
    this.set('gridList', gridList);
});