Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8872057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:07:58+00:00 2026-06-14T18:07:58+00:00

I am using html5Uploader to upload images and everything is working fine. The part

  • 0

I am using html5Uploader to upload images and everything is working fine. The part I am interested is the following:

After images are uploaded, new elements are being added to the DOM (img tag is added for the preview, among others).
After this element is created, I need to be able to attach an on click event. How can I do this (check when this element appears)?

EDIT:

This is the code that is producing preview:

$(function()
    {var fileTemplate="<div id=\"{{id}}\">";
    fileTemplate+="<div class=\"preview\"></div>";
    fileTemplate+="<div class=\"filename\">{{filename}}</div>";
    fileTemplate+="</div>";
    function slugify(text)
    {
        text=text.replace(/[^-a-zA-Z0-9,&\s]+/ig,'');
        text=text.replace(/-/gi,"_");text=text.replace(/\s/gi,"-");
        return text;
    }
$("#dropbox").html5Uploader({
    postUrl: "<?php echo base_url() ?>admin/image_upload",
onClientLoadStart:function(e,file)
    {var upload=$("#upload");
    if(upload.is(":hidden"))
        {upload.show();}
upload.append(fileTemplate.replace(/{{id}}/g,slugify(file.name)).replace(/{{filename}}/g,file.name));},
onClientLoad:function(e,file)
{$("#"+slugify(file.name)).find(".preview").append("<img class=img_upload title=\"" + file.name + "\" src=\""+e.target.result+"\" alt=\"\">");},
onServerLoad:function(e,file)
        {}
    });

And this is the part where I need try to attach on click event:

$('.preview').on('click', '.img_upload', function(){
var _val = textarea.val(),
img_src = '<img src="<?php echo IMG ?>vesti/' + $(this).attr('title') + '" />';
console.log(img_src);
textarea.val( _val + img_src );
});

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:07:59+00:00Added an answer on June 14, 2026 at 6:07 pm

    You can change the code that attaches the image to the preview element

    $("#" + slugify(file.name) ).find(".preview")
        .append( 
            $("<img class=img_upload title=\"" +
            file.name +
            "\" src=\"" + e.target.result + 
            "\" alt=\"\">").on("click", function( ) { // do stuff })
        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the following as an example (with $db being a previously created database connection
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
I am trying to invent hot water :D. I am using html5Uploader and everything
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using the following database table structure: Order Table: OrderId OrderName OrderItem Table: OrderId ItemId
Using the opencart image manager how would I set the upload to automatically remove:
Using the new mvc4 now gives us access to use facebook oauth otb. I
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using SQL Server 2008 R2 we are looking for a way to select the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.