grofit / aurelia-files

A simple attribute plugin for Aurelia to simplify loading files with the HTML5 FileReader
MIT License
15 stars 7 forks source link

Version 0.1.1 #2

Open patrek opened 8 years ago

patrek commented 8 years ago

Following the provided example (copy-paste), I get the following error:

Uncaught Error: You must specify an onLoaded callback at minimum

grofit commented 8 years ago

Can you provide the code you are using as the examples seem to work fine and they use the same source code as the module.

patrek commented 8 years ago

Simply: .js

    textFileLoadedCallback(file, data) {
        document.getElementById('loaded_text_file').innerHTML = data;
    };

.html

<label for="text_file">Load Single Text File</label>
                        <input type="file" id="text_file"
                               files="on-loaded.bind: textFileLoadedCallback; file-filter.bind: 'text.*|application.*'; read-as.bind: 'text';" />
                        <div id="loaded_text_file"></div>

And main.js

aurelia.use.plugin('aurelia-files');
grofit commented 8 years ago

just to confirm your js stuff is within a class/viewmodel which is assigned right? as that error is because you have either not passed it a method (Which your code says you have) or the value you provided it is falsey (undefined, null etc).

If you can post an isolated repro I am happy to take a look, the code is pretty trivial so if you want to just open up the plugins attribute method and put a console.log in to check what the binding you are passing in is, if its not falsey then there is something more odd happening.