Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom "Choose file" button not working #87

Open
tab00 opened this issue Jan 28, 2016 · 2 comments
Open

Custom "Choose file" button not working #87

tab00 opened this issue Jan 28, 2016 · 2 comments

Comments

@tab00
Copy link

tab00 commented Jan 28, 2016

When using a custom template for the "Choose file" button by creating a template as in the ReadMe example:

<template name="mySelectFileBtn">
  <button type="button" class="js-af-select-file">Upload file</button>
</template>

and setting selectFileBtnTemplate: 'mySelectFileBtn' in the schema, the button renders correctly. However a file dialog does not appear when clicked.

When I inspected the original "Choose file" HTML code, there is an input tag of type "file" in the button. So I tried to do the same in the custom template:

<template name="mySelectFileBtn">
  <button type="button" class="js-af-select-file">Upload file
<input type="file" class="js-file">
</button>
</template>

This opens the file dialog when clicked, however after choosing a file there is no result, nor is there any error message.

I should add that element input should not be nested inside element button, as that is invalid HTML.

Please fix the problem(s).

@isbjorn
Copy link

isbjorn commented Jan 31, 2016

Try this:
#85 (comment)

@diegonc
Copy link

diegonc commented Apr 21, 2016

There's one more bit of code that's missing from the custom upload button example and it is activating the jQuery file upload plugin. In addition to what @isbjorn suggest, I had to add that bit:

Template.mySelectFileBtn.onRendered(function () {
  this.$(".js-file").fileupload();
});

The built-in button has that code here, which won't be executed with a custom template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants