Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just found the answer I needed on another question, but it was never accepted. The answer is by Mario Bellart, <a href="https://stackoverflow.com/questions/13988202/fire-onappend-event-for-jquery-element-when-it-gets-appended-to-the-dom">Fire OnAppend event for jQuery element when it gets appended to the DOM</a></p> <p>How I adapted his code</p> <pre><code>//Create the dropdown box for the items var Items = document.createElement("select"); $(Items).attr( {"id":"Items"} ); $(document).on("append", Items, function(){ $(Items).chosen({disable_search_threshold: 100}); $("#Items_chosen").css({"width":"100px","position":"absolute","left":"5px","top":"20px"}); } ); $(document).on("change",Items, function(){ updateHolder(true); $(InfoBox).trigger("chosen:updated"); setTimeout( function(){ $(Items).data('chosen').input_blur(); }, 100 ); } ); //Add items from ED.listOfItems to HTML Items dropdown box for(var it in ED.listOfItems){ var iKey = ED.listOfItems[it]; var itemOption = document.createElement("option"); if(!Array.isArray(iKey)){ $(itemOption).val(iKey); $(itemOption).html(iKey.split("_")[0]); } else{ $(itemOption).val(iKey[0]); $(itemOption).html(iKey[1]); } $(Items).append( itemOption ); } /*******Set default to spawn*******/ /**/ ED.objectType = "Spawn"; /**/ /**/ ED.infoType = ""; /**/ /**/ $(Items).val("Spawn"); /**/ /**********************************/ $(MenuBar).append(Items).trigger("append"); </code></pre> <p>I did not know about .trigger() and creating custom events. Maybe I should do some more reading up.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload