I am using :empty
on a span that is loaded via a jQuery $.post()
.
In Internet Explorer 11 when the span gets filled the :empty
CSS definition is still applied to the span. When I click anywhere in the body of the page, the :empty
definition is removed and the page is styled the way it should be.
It seems to work as expected in Chrome.
Is there a way in javascript/jQuery to force IE to remove the :empty
pseudo class from the span when the jQuery call completes?
Below is the CSS definition in question;
#widgetContainer span[id^="wdg_"]:empty, .widget_placeholder:empty {
background-color: #ccc;
border: 5px dashed #999;
border-radius: 0px;
width: 300px;
line-height: 300px;
text-align: center;
}
And here is a the javascript function I run to load the "widgets" note: I am using ASP.NET MVC so that is why the load functions first parameter looks a little funky;
function loadWidget(id) {
var $wdgt = $("<span id='wdg_" + id + "'>");
$wdgt.appendTo($("#widgetContainer"));
$wdgt.load('@Url.Action("GetWidget", "Dashboard")', { widgetID: id }, function (data) {
var init = window["initWidget" + $(this).find("#widgetID").val()];
if (typeof init === 'function') {
init();
}
$("#widgetContainer").sortable("refresh");
});
}