Upload background-image

72 Views Asked by At

When giving a div the .bgimg class, users right click that div is directed to a pop up that has an file uploader to replace the background-image of that div.

Im using both contextmenu.js and BlueImps fileupload.js which both works perfectly with editing inline images.

The only thing need fixing now is this code, which seems to only replace images of child divs instead of the div with

$.contextMenu({
selector: '.bgimg',
className: 'data-img-title',
callback: function(key, options) {
    $('.context-menu-active').addClass('imgbg');
    $("#ImagePopUp").dialog('open');
    $("#ImagePopUp").parent().removeClass('imgbg');
    bgpname = $(this).parent().attr('id');
    $("#ImagePopUp").parent().addClass('imgbg');
    $(document).on("click", "#imageselectbg", function() {
        var comgetval = $('#ImagePopUp #bgget').html();
        $('#' + bgpname).css('background-image', "url(" +
            comgetval + ")");
    });
},
items: {
    "edit": {
        name: "Edit background",
        icon: ""
    },
}

});

I'm no expert with js so I hope someone can help me with this.

0

There are 0 best solutions below