Lazily bind forms for form support #1334

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

Projects

None yet

2 participants

@mrjoelkemp
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
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
Contributor

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
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
Contributor

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

@rnicholus rnicholus added 2 - Do and removed 0 - Discuss labels Feb 4, 2015
@rnicholus rnicholus added this to the 5.3.0 milestone Apr 17, 2015
@rnicholus rnicholus modified the milestone: 5.3.0, 5.4.0 Jul 6, 2015
@rnicholus rnicholus added 3 - Doing and removed 2 - Do labels Jul 22, 2015
@rnicholus
Member

Looking into this now as part of 5.3.0 work.

@rnicholus rnicholus added 5 - Done and removed 3 - Doing labels Jul 22, 2015
@rnicholus
Member

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

@mrjoelkemp
Contributor

Awesome work! Thanks.
On Jul 22, 2015 1:07 PM, "Ray Nicholus" notifications@github.com wrote:

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


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

@rnicholus rnicholus closed this in bb0ff30 Aug 3, 2015
@rnicholus rnicholus removed the 5 - Done label Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment