简体   繁体   English

如何实例化多个jQuery文件上传?

[英]How to instantiate multiple jQuery File Uploads?

So basically, I am having a hard time trying to create multiple jQuery File Uploads . 所以基本上,我很难创建多个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. 当前,我在页面上有一个按钮,允许用户创建一个新的div ,其中包含文本输入和一些图形。 I would like to add a file upload part to of these new div s they create so that they can attach images. 我想在他们创建的这些新div添加文件上传部分,以便它们可以附加图像。 The number of new div s that can create is unlimited. 可以创建的新div数量是无限的。 The divs are created from a long Javascript string and appended to the end of a container. div是由一个长Javascript字符串创建的,并附加到容器的末尾。

I would like to use the 'Basic Plus UI' version since it has a better and cleaner interface. 我想使用“ Basic Plus UI”版本,因为它具有更好,更简洁的界面。

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. 我的代码必须与$(this)一起使用,以确保每个上传器都与其他上传器完全分开。 The plugin currently works with IDs and not classes, so I would have to find away around this also. 该插件当前仅适用于ID,而不适用于类,因此我也必须解决这一问题。

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(.. 据我所知,对于动态创建的对象,您应该通过$(selector).on(..

As example: 例如:

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

or live(..) instead on(..) in old versions of JQuery live(..)而不是旧版本的JQuery中的on(..)

You can more read about it here: https://api.jquery.com/on/ 您可以在这里了解更多信息: https : //api.jquery.com/on/

It should help . 它应该有所帮助。 . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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