jeudi 30 avril 2015

One way binding from DOM element to Controller property - Ember

In my ember application I've a file input DOM element. I bind the value attribute of the element to a controller property.

I do this to know when the file input's value changes. But I don't want to set the value from the controller. I mean one way binding. DOM element to controller and not controller to DOM element.

Handlebar code :

{{input type="file" name="pic" accept="image/*;capture=camera" id="newImage" value= imagePath}}

Controller :

App.ExampleController = Ember.ObjectController.extend({
    imagePath: null,
    imageChanged: function () {
        //Some Code
    }.observes('imagePath')
});

I need this because I get the following error

Uncaught InvalidStateError: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string. thrown by jquery-1.11.1.min.js

Is there a way to fix this ?




Aucun commentaire:

Enregistrer un commentaire