How do I programatically add cloudinary file inputs via jQuery after page load is complete?
I'm building an application where a user may upload an arbitrary number of images. The images are uploaded to cloudinary, previewed on the page (after a transformation is applied), and either saved (public id saved to my django app) or forgotten forever ("discarded").
I'm running into a problem where I'm trying to programatically add the cloudinary file upload inputs after the page is done loading (via javascript, a handlebars template to be specific). It doesn't seem like any of the cloudinary functionality is attaching itself to inputs that are added to the DOM after pageload.
For example, images aren't sent to cloudinary after they're seleted in the system file picker. Upload events like cloudinarydone aren't being fired (yes, I am binding using on() correctly). What am I doing wrong here?
If there would be an easy way to generate the input element after pageload, using some sort of javascript (sort of like the {% cloudinary_direct_upload_field %} tag, but client side), that is ideally what I'm looking for.
Thanks for your help!
-
Hi Patrick,
You'll need to call
$(selector).cloudinary_fileupload()
on any new input element that's added to the DOM after page load.0
Post is closed for comments.
Comments
1 comment