简体   繁体   中英

How to instantiate multiple jQuery File Uploads?

So basically, I am having a hard time trying to create multiple jQuery File Uploads .

Currently, I have a button on my page that allows a user to create a new div that contains text inputs and a few graphs. I would like to add a file upload part to of these new div s they create so that they can attach images. The number of new div s that can create is unlimited. The divs are created from a long Javascript string and appended to the end of a container.

I would like to use the 'Basic Plus UI' version since it has a better and cleaner interface.

Some very basic instructions are displayed on the site on how to have multiple file upload widgets on the same page , although I am not to sure if this is possible or not with dynamic creation.

The main problems I am facing: The uploader appends the selected images with their information to a section below it. My code would have to work with $(this) to make sure that each uploader is completely separate from the others. The plugin currently works with IDs and not classes, so I would have to find away around this also.

Of course, I am not asking anyone to write a ton of code for me! Just some guideance on how to approach this would be great.

As i know, with dynamically created objects you should work through $(selector).on(..

As example:

$('.parent_container').on('click', '.btn', function(){
// do something
})

or live(..) instead on(..) in old versions of JQuery

You can more read about it here: https://api.jquery.com/on/

It should help . . .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM