-
Notifications
You must be signed in to change notification settings - Fork 61
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
Is it possible to make a div clickable and allow drag and drop? #152
Comments
Hello! No! For a clickable element, an input is always necessary. The native file chooser dialog only appears from clicking on an input type=file. Either as a hidden underlying, or hidden somewhere else and raise the click event on the input during some arbitrary click event. |
@Tewr Could you be more clear on how this would work ? The thing is I think I can't do that, because if I do, I will need two I'm not sure how to simulate a clickable div that will click on the input (with js) and also allow drag and drop because of the need to call |
If I would do this, I would create a div as in the first example. Once that works, add two inputs, as in the second example. Manage a common stream reference (or a common list of streams, if you want to support multiple files) using the drop event on the div, and the change event on the inputs. You would call createReference three times, one for the div and one for each input type=file. An alternative, that I haven't really tried, would be to keep a single large input as in the second example, and add an element on top of it that doesn't bubble down the clicks. And then on the two buttons you do allow bubble down of the clicks. On the top of my head I'm not sure if that solution involves additional JavaScript though, might be a bit tricky. |
I have something alike and i just handle the click event on the div and trigger a js function that clicks the invisible file upload button. |
@Tewr the short answer I think it's yes but is not straight forward. He would need to make a div element trigger the input file click event. I already did this using this library. |
I did something similar with a clickable div. In my case, I used a button to trigger the click on a hidden input.
In order to trigger the input to upload, I bound the input control like this: then the filelist can run a method to do something like this: In my PR, I have included a way to drag/drop multiple files and folders at the same time and it will track the relative paths of the tree. The GUI is my own gui, but you can see I have a button that says select files and a drag/drop area. I could have made the div clickable in this case instead of the button. |
In the drag and drop example you either have a div with drag and drop or a hidden clickable input with drag and drop.
Is there a way to make a div clickable too?
The text was updated successfully, but these errors were encountered: