javascript - Select2 blocks while images load into DOM -


i use select 2 show entries database have imageurl.

my format-function dropdown items looks this:

function formatdropdown(item) {             var result = "<img src='" + item.mapimageurl + "'>&nbsp;" + item.name             return result;         } 

item.mapimageurl contains simple url image should displayed.

now server takes second or 2 resolve images beiing displayed. unfortunately dropwdown blocks in time.

i create select2 following code:

    stationselector.select2({         placeholder: 'choose station',         allowclear: true,         data: { results: stations, text: 'name' },         formatselection: formatdisplay,         formatresult: formatdropdown, 

is there way make select not waiting / blocking till image loaded? nice, if use / open box without blocking , images appear afterwards.

are there extensions deferred image loading?

at least found solution.

using style sets background, doesnt cause issue.

so format method looks this:

  function formatdropdown(item) {                 var result = "<div style='background-image:url('" + item.mapimage + "');'></div>&nbsp;" + item.name;             return result;         } 

the select2 isn't blocking anymore , can see slower images resolved asynchronously afterwards.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -