lundi 18 janvier 2016

Initiate jQuery Plugin in Ember Cli

How can i initiate a jQuery plugin in Ember-Cli?

I am trying to use Masonry plugin and this is the logic i want to implement

var $grid = $('.grid').masonry({
  itemSelector: '.grid-item',
  percentPosition: true,
  columnWidth: '.grid-sizer'
});
// layout Isotope after each image loads
$grid.imagesLoaded().progress( function() {
  $grid.masonry();
}); 

I am trying to use the event hook called didInsertElement, but the jQuery plugin does not initiate.

Here my code

import Ember from 'ember';

var PhotographyController = Ember.ObjectController.extend({
    didInsertElement : function(){
      this._super();
      Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
    },

    afterRenderEvent : function(){
      var $grid = $('.grid').masonry({
        itemSelector: '.grid-item',
        percentPosition: true,
        columnWidth: '.grid-sizer'
      });
      // layout Isotope after each image loads
      $grid.imagesLoaded().progress( function() {
        $grid.masonry();
      });  
    }
});

export default PhotographyController;

How can i initiate the Plugin and implement this logic?

I am using Ember 1.3.11




Aucun commentaire:

Enregistrer un commentaire