Skip to content
This repository has been archived by the owner on Nov 20, 2018. It is now read-only.

Lazily bind forms for form support #1334

Closed
mrjoelkemp opened this issue Dec 12, 2014 · 7 comments
Closed

Lazily bind forms for form support #1334

mrjoelkemp opened this issue Dec 12, 2014 · 7 comments
Milestone

Comments

@mrjoelkemp
Copy link
Contributor

I have a use case where one popup shows the upload button (instantiating an uploader) and after submission, another popup renders the submitted image along with a form (for annotating the image). The form does not exist at the time of uploader creation, but I would still like to leverage form support (since the submitted image is to be uploaded along with the form data).

I know that the form is expected to be part of the uploader's initialization options, but is there currently a way to bind to a form after instantiation?

If there is no current way of doing this, do you see value in lazy binding? I'm thinking of something like a uploader.bind($form) as the public api. If a form element is supplied in the options, fineuploader would then call bind internally.

@rnicholus
Copy link
Member

Fine Uploader doesn't depend on jQuery internally. In fact, I'm toying with the idea of deprecating/removing the jQuery wrapper in a future version, see #1310 for details.

Seems like it wouldn't be difficult to add an API method to update/set the bound form, which could be called anytime after init.

@mrjoelkemp
Copy link
Contributor Author

Apologies, jquery wasn't an important part of the api (only habitually added it). Replace that with a dom node representing the form.

Glad to hear there's value in adding the capability to core. Any foreseeable hiccups with implementing this? Any good place to start digging? I'll likely implement it in my fork (for immediate use in production) and potentially bring it to fineuploader core if it works.

Thanks for your speedy response and continued support.

@rnicholus
Copy link
Member

Well you know how it is. First step is to say something is trivial. Second step is to start working on it and realize that you've opened a can of worms.

That said, this doesn't appear to be an overly difficult adjustment. I would imagine a new public method would be added to the API: setForm. The parameter would be either an HTMLFormElement or an ID selector string for the form (once we officially drop support for IE7 in 6.0 #637 these selector strings can be much more complex since we can utilize querySelector/querySelectorAll) .

When the new API method is called, Fine Uploader will run the _initFormSupportAndParams internal method, passing in the new form selector/element. Some modifications will be required to this private method.

@mrjoelkemp
Copy link
Contributor Author

Thanks for the details @rnicholus. I'll give it a go in my fork and report back.

@rnicholus
Copy link
Member

Looking into this now as part of 5.3.0 work.

@rnicholus
Copy link
Member

This is complete in the develop branch - 5.3.0-7.

@mrjoelkemp
Copy link
Contributor Author

Awesome work! Thanks.
On Jul 22, 2015 1:07 PM, "Ray Nicholus" [email protected] wrote:

This is complete in the develop branch - 5.3.0-7.


Reply to this email directly or view it on GitHub
#1334 (comment)
.

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

No branches or pull requests

2 participants