Insert object (jquery) delay?

前端 未结 6 477
天命终不由人
天命终不由人 2021-01-12 21:49

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

6条回答
  •  不要未来只要你来
    2021-01-12 22:25

    Did you try use the reference you already have?

    var obj = jQuery('
    ', { id: objId, class: 'object_image', }).appendTo('#objectbox'); restoreSize(obj);

    Maybe it works

    EDIT: You can put a timeout 0 to append your function after the browser render...

    var obj = jQuery('
    ', { id: objId, class: 'object_image', }).appendTo('#objectbox'); setTimeout(function(){ restoreSize(obj) }, 0);

提交回复
热议问题