Files.bind issue

Hello,

In my application I am loading a form component where I want to have a file field as well. I have created custom components for each input type.

So I have form-filedrop.html

<template>
	<div class="form-filedrop">
		<label>${label}</label>
		<input type="file" files.bind="selectedFiles">
	</div>
</template>

And form-filedrop.ts

import { autoinject, bindable } from "aurelia-framework";

@autoinject
export class FormFiledrop {
	@bindable label = "Files";
	selectedFiles: FileList;
}

And then in my form view (simplified):

<template>
	<require from="resources/components/form/form-filedrop"></require>
</template>

<div>
	<form-filedrop label="File"></form-filedrop>
</div

But somehow this makes the whole form appear blank in my site… (no error in console)

However - I the following works:

form-filedrop.html

<template>
	<div class="form-filedrop">
		<label>${label}</label>
		<input type="file" files="on-loaded.bind: filecallback">
	</div>
</template>

form-filedrop.ts

import { autoinject, bindable } from "aurelia-framework";

@autoinject
export class FormFiledrop extends FormElement {
	@bindable label = "Files";
	filecallback = (file, data) => {
	 	console.log(file);
	}
}

So I can bind to a function, but not to a FileList property.

Anyone have any tips to push me in the right direction to get this sorted?

If the whole form turns blank, I think it’s either html structure or css issues, could you check that? Also from what it looks like, there shouldn’t be any issues. Can you share a small repro based on this https://codesandbox.io/s/zw9zjy0683

Thanks @bigopon - it’s not html/css problems as inspecting the code shows that the form is not loaded at all. Also the one thing that makes it load or not load is if I have the files.bind binding on the input or not.

One thought… the Aurelia app in question was started late 2016/early 2017 - could it be a problem that the Aurelia version is to old?

If it’s not loaded, then it’s probably something else, like mismatching names. The frameworks hasn’t gone through a breaking change for its core templating feature, so it shouldn’t break your app. I would suggest renaming everything, and move that component to a different folder to track where the issue(s) is/ are.

Thanks again :smile:

I’m asigned to another project the rest of the week, but will try your suggestions on monday when I’m back on that project.

Sure. Update here when you have a chance :smiley: