SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery append before not after?

    I'm working on this multiple upload script and it works just fine except for each new upload image I start it appends the file after the last one... I would like it to show as the first one...

    Code JavaScript:
    onSubmit: function(file, ext){
    	 if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
    		// If the ext. is not allowed 
    		status.text('Only JPG, PNG or GIF files are allowed');
    		return false;
    	}
    	mynewLI = jQuery('<li></li>').appendTo('#files').html('<img src="modules/ajaxMultiUpload/waiting.gif" />').addClass('success');
    	jQuery('#files').data(file, mynewLI);
    },
    onComplete: function(file, response){
    	//Add the file to a list
    	var mynewLI = jQuery('#files').data(file);
    	if(response==="success"){
    		file = file.replace(/ /g,"-");
    		file = file.toLowerCase();
     
     
    		mynewLI.html('<img src="modules/ajaxMultiUpload/uploads/thumb_'+file+'" alt="" />').addClass('success');
    	} else if(response==="error1"){
    		mynewLI.html('Wrong dir...').addClass('error');
    	} else{
    		mynewLI.html('Something went wrong?<br><br>'+response).addClass('error');
    		//mynewLI.text(file).addClass('error');
    	}
    }

    Any ideas to how to do so?

  2. #2
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry... prependTo

    My Bad ;-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •