I allow the user to insert an object, an image, and then i call a function on that object. What seems randomly to me, sometimes it works and sometimes not, I guess it has t
could this work for you?
function add_image(img) {
var objCount = count_objects() + 1;
var objId = 'object_' + objCount;
var myNewImg = jQuery('', {
id: objId,
class: 'object_image invisible'
}).appendTo('#objectbox');
$('#' + objId).attr('namn', objId)
$('#' + objId).addClass('lockedAspectRatio')
var imgInner = jQuery('', {
id: objId,
'class': 'object_image_inner',
src: img
}).load(function () {
imgInner.appendTo('#' + objId)
restoreSize(myNewImg, imgInner);
$(myNewImg).removeClass('invisible');
});
window.objectCounter++;
prepare_editmode();
//reset the flag and the temporary image field now that image adding is complete
$('#imageGhost').val(null);
}
and BTW you've duplicate ids for myNewImg
and imgInner