louisremi / background-size-polyfill

Adds support for background-size "cover" and "contain" to IE8
http://louisremi.github.com/background-size-polyfill/
MIT License
1.26k stars 359 forks source link

Add a way to trigger updates from site JS #41

Open jefferyto opened 10 years ago

jefferyto commented 10 years ago

Folks are using this with elements that are styled dynamically with JS (#31, https://github.com/louisremi/background-size-polyfill/issues/15#issuecomment-33117627, https://github.com/louisremi/background-size-polyfill/issues/32#issuecomment-33461611), so we need a way for site scripts to trigger an update after they're done styling.

jefferyto commented 10 years ago

Until this is done, a workaround is to "touch" the element, i.e. assign to any property of the DOM object (it doesn't matter if the property value remains unchanged).

For example, if the elements that use the polyfill all <div class="bg">, then this should cause an update:

$('div.bg').prop('class', 'bg');
rubensayshi commented 10 years ago
$('div.bg').get(0).style.behavior = $('div.bg').get(0).style.behavior;

does the trick

jefferyto commented 10 years ago

Thanks @rubensayshi - as I said, a workaround is to assign any value (even the same value) to any property.

leup commented 10 years ago

:+1: