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 + "'> " + 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> " + item.name; return result; }
the select2 isn't blocking anymore , can see slower images resolved asynchronously afterwards.
Comments
Post a Comment