开发者

IE doesn't apply css styles to a dynamically added div

I have this weird problem on IE8. My application get a div via ajax and append it to the HTML.

$('#formPromocao').submit(function () {
        persistPageIndex();
        var postData = $(this).serialize();
        $.post($(this).attr('action'), postData, function (data) {
            $('#lista').empty();
            $('#lista').append(data);
  开发者_运维问答          prepareNewForm();
        });
        return false;
    });

This works perfectly on all browsers except IE8 the appended HTML is not stylized by the browser and I cant figure out why.

Has anyone here stumbled upon this issue before? Any help would be appreciated.

EDIT:

I have found the problem: The HTML people used HTML5 for the application and on IE8 there's a script that handles HTML5: http://html5shiv.googlecode.com/

I have to find a way to make this script run again when the HTML is updated. Can I safely do this?


Use the shiv function before appending to the document:

html = innerShiv(html, false);
$('something').append(html);


This is usually because you are appending invalid HTML, or there is already invalid HTML in the page.


Here is how I managed to append HTML5 in IE.

I found this amazing script: http://jdbartlett.github.com/innershiv/#download and then all I had to to was to append the result of innerShiv to the HTML:

$('#formPromocao').submit(function () {
        persistPageIndex();
        var postData = $(this).serialize();
        $.post($(this).attr('action'), postData, function (data) {
            $('#lista').empty();
            $('#lista').append(innerShiv(data));
            prepareNewForm();
        });
        return false;
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜