mardi 25 août 2015

Error while inserting "input type=file" on an absolute div having action - ember.js

In my ember application I need to upload an image and need to capture the change of files. So I used an view in the following manner

export default Ember.TextField.extend({
  type: 'file',
  accept: 'image/*',

  click: function() {
    this.dispatchEvent(event.originalEvent);
    return false;
  },

  change: function(evt) {
    console.log("Photo upload");
  }
});

The "click" event is handled separately for a reason. This view was working properly till I used this inside another view which itself handled an action on a whole.

So I had to to handle this event explicitly and return false.

Now the error I encountered here is..

Uncaught TypeError: this.dispatchEvent is not a function

I searched and found that this could be happening because of conflicts with JQuery's $ variable and I should add

<script>jQuery.noConflict();</script>

But I'm not sure where to add this in Ember-CLI.

Now there could be two fixes here, I should call the original event of the "file" field or add "jQuery.noConflict()" at the right place.

Please provide me with the fix or any way which is right to achieve this functionality.




Aucun commentaire:

Enregistrer un commentaire