Clicking this button will change ch5-image url into invalid value. A listener on the error event is triggered and will change the url value to 'http://via.placeholder.com/300x200' ( See the JS tab )
<p>Clicking this button will change ch5-image url into invalid value. A listener on the error event is triggered and will change the url value to 'http://via.placeholder.com/300x200' ( See the JS tab )</p> <p> <button id="bad-url" class="button is-info" type="button">Change URL</button> </p> <ch5-image id="demo" width="300px" height="200px" url="https://www.crestron.com/Crestron/media/Crestron/GeneralSiteImages/Featured%20Pages/Digital%20Media/all-in-one.jpg"> </ch5-image>
$('#bad-url').on('click', function(){ $('#demo').attr('url', 'http://bad-url-triggers-error-event'); }); $('#demo').on('error', function(){ console.log('image error event'); $(this).attr('url', 'http://via.placeholder.com/300x200'); });