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 6707537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:39:05+00:00 2026-05-26T07:39:05+00:00

I have a problem. I upload some images from HDD to the website using

  • 0

I have a problem.

I upload some images from HDD to the website using Ajax;
on success I append the result inside a list that show the image and a button for delete the image (the delete process is in ajax too).

If I load an image the button for delete doesn’t work, it works only after one refresh.

How can I bind it to work on ajax success as well?

var uploader = new qq.FileUploader({
            element: document.getElementById('file-uploader-demo1'),
            allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
            sizeLimit: 21474836, // max size
            action: '/FileUpload/FileUpload',
            multiple: false,
            debug: true,
            params: {
                param1: imgId
            },
            fileTemplate: '<li>' +
                    '<span class="qq-upload-file"></span>' +
                    '<span class="qq-upload-spinner"></span>' +
                    '<span class="qq-upload-size"></span>' +
                    '<a class="qq-upload-cancel" href="#">Cancel</a>' +
                    '<span class="qq-upload-failed-text"></span>' +
                '</li>',
            onComplete: function (id, fileName, result) {
                var lista = $('ul.uploaded-images');
                lista.prepend('<li><img src="/img/' + imgId + '/' + result.filename + '" /><a id="delete" class="ir delete" href="">delete</a></li>');
                buttonEvents();
                qq.FileUploaderBasic.prototype._onComplete.apply(this, arguments);

                // mark completed
                var item = this._getItemByFileId(id);
                qq.remove(this._find(item, 'cancel'));
                qq.remove(this._find(item, 'spinner'));

                if (result.success) {
                    qq.addClass(item, this._classes.success);
                } else {
                    qq.addClass(item, this._classes.fail);
                }

            }
        });

Thanks in advance for your help.

  • 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-05-26T07:39:06+00:00Added an answer on May 26, 2026 at 7:39 am

    When binding an event in jQuery, the event is added to all elements in the jQuery element set created by your jQuery selector. This is done only once and if you add elements that would match that selector, you still have to bind the events to the newly inserted elements. Or alternatively; you can use .live();.

    // bind a callback to the click event of all
    // elements currently present with id "delete" 
    $('#delete').click(callback);
    
    // bind a callback to the click event of all
    // elements currently present with id "delete" 
    $('#delete').bind('click', callback);
    
    // bind a callback to the click event of all elements currently present 
    // with id "delete", and elements that are later inserted with id "delete"
    $('#delete').live('click', callback);
    

    I am also noticing 2 things in your code that might cause problems:

    1. You are prepending an element with a static ID attribute. It is recommended to only use a certain ID once per page.
    2. buttonEvents(); might be your callback to bind the events to the buttons. If this is the case; you are binding the events to all buttons every time a button is added, resulting in the event being bound to some buttons multiple times.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash script to upload some files to my webserver. The problem
I'm using Uploadify to upload some images with ASP.NET. I use Response.WriteFile() in ASP.NET
I have some problem for decoding image data from base 64 encoded string. I
I have some C# code that will upload images and files into a db.
I have written some code to share images on Facebook using Sharekit. The code
I'm developing small FTP upload app. for mac (10.6 if it matters) Have problem
I'm using SWFUpload to handle file uploads and have run into a problem where
I have problem in some JavaScript that I am writing where the Switch statement
I have problem when I try insert some data to Informix TEXT column via
I have created a helper that requires some parameters and should upload a file,

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.