function createImageItem(imgid, imgUrl, thumbUrl) {
    //Row container.
    var row = $('<div id="'+imgid+'" class="row img-item ui-widget-content">');
    //Create thumbnail.
    var thumb = $('<div id="thumb-'+imgid+'" class="thumb col-3">');
    thumb.append('<img src="'+thumbUrl+'"></img>');
    //Create link for the image.
    var link = $('<div class="col-9">');
    link.append('<a class="imglink" href="'+imgUrl+'"> Image: '+imgid+'</a>');
    //Create remove button for the image.
    var delImgBtn = $('<button/>', {
        text: 'Delete',
        id: 'del_'+imgid,
        click: function () {
            var is_confirmed = confirm("This image will be removed!");//Confirm before deleting.
            if(is_confirmed) {
                $.ajax({
                    url: ImageApiUrl+imgid,
                    type: "DELETE",
                    processData:false,
                    contentType: "application/json"
                }).done(function (data, textStatus, jqXHR){
                    $('#image-list #'+imgid).remove();//If it is removed from DB, remove from image list too.

                }).fail(function (jqXHR, textStatus, errorThrown){
                    console.log ("RECEIVED ERROR: textStatus:",textStatus, ";error:",errorThrown);
                });
            }
        }
    });
    link.append(delImgBtn);
    row.append(thumb);
    row.append(link);
   return row;
}
//Returns a row of image as DIV element.
Returns a row of image as DIV element.
Returns a row of image as DIV element .
function createImageItem(imgid, imgUrl, thumbUrl) {
    var row = $('<div id="'+imgid+'" class="row img-item ui-widget-content">');
    var thumb = $('<div id="thumb-'+imgid+'" class="thumb col-3">');
    thumb.append('<img src="'+thumbUrl+'"></img>');
    var link = $('<div class="col-9">');
    link.append('<a class="imglink" href="'+imgUrl+'"> Image: '+imgid+'</a>');
    var delImgBtn = $('<button/>', {
        text: 'Delete',
        id: 'del_'+imgid,
        click: function () {
            var is_confirmed = confirm("This image will be removed!");
            if(is_confirmed) {
                $.ajax({
                    url: ImageApiUrl+imgid,
                    type: "DELETE",
                    processData:false,
                    contentType: "application/json"
                }).done(function (data, textStatus, jqXHR){
                    $('#image-list #'+imgid).remove();
                }).fail(function (jqXHR, textStatus, errorThrown){
                    console.log ("RECEIVED ERROR: textStatus:",textStatus, ";error:",errorThrown);
                });
            }
        }
    });
    link.append(delImgBtn);
    row.append(thumb);
    row.append(link);
   return row;
}
function createImageItem ( imgid , imgUrl , thumbUrl ) { var row = $ ( '<div id="' + imgid + '" class="row img-item ui-widget-content">' ) ; var thumb = $ ( '<div id="thumb-' + imgid + '" class="thumb col-3">' ) ; thumb . append ( '<img src="' + thumbUrl + '"></img>' ) ; var link = $ ( '<div class="col-9">' ) ; link . append ( '<a class="imglink" href="' + imgUrl + '"> Image: ' + imgid + '</a>' ) ; var delImgBtn = $ ( '<button/>' , { text : 'Delete' , id : 'del_' + imgid , click : function ( ) { var is_confirmed = confirm ( "This image will be removed!" ) ; if ( is_confirmed ) { $ . ajax ( { url : ImageApiUrl + imgid , type : "DELETE" , processData : false , contentType : "application/json" } ) . done ( function ( data , textStatus , jqXHR ) { $ ( '#image-list #' + imgid ) . remove ( ) ; } ) . fail ( function ( jqXHR , textStatus , errorThrown ) { console . log ( "RECEIVED ERROR: textStatus:" , textStatus , ";error:" , errorThrown ) ; } ) ; } } } ) ; link . append ( delImgBtn ) ; row . append ( thumb ) ; row . append ( link ) ; return row ; }
Returns a row of image as DIV element.
Returns a row of image as DIV element .
//Row container. //Create thumbnail. //Create link for the image. //Create remove button for the image. //Confirm before deleting. //If it is removed from DB, remove from image list too.