dimanche 8 mai 2016

Trying to wrap a jQuery plugin as an Ember component

I'm trying to wrap the Hootsuite Grid plugin as an Ember component:

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();
  }
});

When I console.log(this); I can see that the options are correctly set on the parent object, but not passed to the internal gridList object

Properties in Chrome expor

Whereas these values seem to be passed to the child object in the test fiddle that I was playing:

http://ift.tt/1UKZpzW

enter image description here

Am I doing something wrong?




Aucun commentaire:

Enregistrer un commentaire