开发者

Does IE7 have a problem applying CSS to dynamically created DOM Elements?

I'm building an HTML page that uses endless scrolling functionality to render new list elements as you scroll down, like on Facebook. I'm using the jquery.pageless plugin.

The thing is, now testing it on IE7, when I load the dynamic content, none of it is styled like it should be. The first set (20 rows), which the server generated in the html page, look fine. Then the next 20-per-page that are rendered with javascript, don't have any of the styles applied.

How do I fix this? Having a h开发者_如何学Goard time testing it in IE7 from a mac. Is this a problem with IE7? Or could perhaps the elements not be being appended to the correct parent div in IE (using jQuery so I doubt this)? Or is there a common hack for reloading the stylesheets after every dynamically created html element is added?

The doctype is HTML5: <!DOCTYPE html>

Thanks for the advice!

Update:

Looking in the IE7 developer panel, the HTML is being spit out all malformed. The first time around it looks like this:

<article class='community-page page none vevent' data-status='available' data-type='community_page' itemscope='itemscope' itemtype='http://www.data-vocabulary.org/Event'>
  <figure class='snapshot'><time class='availability dtstart' datetime='2010-12-16T00:00:00-08:00' itemprop='startDate' title='2010-12-16T00:00:00-08:00'><span class='value-title' title='2010-12-16T00:00:00-08:00'></span></time><a href="/users/25?page_id=25" class="fancy-ajax logo"><span></span><img alt="Logo for Heavenly Cleaning" class="photo" src="/images/41/heavenly-cleaning-logo-small.JPG?1297971958" title="Logo for Heavenly Cleaning" /></a>
    <a href="/pages/25/bookmarks" class="status bookmark">Like</a>
  </figure>
  <section class='details' itemprop='seller' itemtype='http://data-vocabulary.org/Organization'>
    <header class='header'>
      <hgroup>
        <h3 class='user fn org' itemprop='name'>
          <a href="/users/25?page_id=25" class="fancy-ajax">Name</a><span class='hyphen'>-</span><span class='distance'>Wheaton, IL</span>
        </h3>
        <h2 class='title'><span class='quotation-mark'>"</span><a href="/users/25/pages/25" class="url summary">Quote</a><span class='quotation-mark'>"</span><time class='expiration-date dtend'><span class='value-title' title='2011-12-16T00:00:00-08:00'></span></time></h2>
      </hgroup>
    </header>
    <p class='highlights'></p>
    <p class='description' itemprop='description'></p>
    <footer class='footer'>
      <address class='location adr' itemprop='address' itemscope='itemscope' itemtype='http://data-vocabulary.org/Address'>
        <span class='locality' itemprop='locality'></span>
        <span class='geo' itemprop='geo' itemtype='http://data-vocabulary.org/Geo'>
          <span class='latitude' itemprop='latitude'>
            <span class='value-title' title='41.850249'></span>
          </span>
          <span class='longitude' itemprop='longitude'>
            <span class='value-title' title='-88.0855459'></span>
          </span>
        </span>
        <span class='tel' itemprop='tel'></span>
      </address>
      Category: <a href="/pages/home" class="category" itemprop="category" rel="tag" target="_top">Home</a>
    </footer>
  </section>
</article>

The second time around it looks more like this:

<article class='community-page page none vevent' data-status='available' data-type='community_page' itemscope='itemscope' itemtype='http://www.data-vocabulary.org/Event'/>
<figure class='snapshot'/>
<time class='availability dtstart' datetime='2010-12-16T00:00:00-08:00' itemprop='startDate' title='2010-12-16T00:00:00-08:00'/>
<span class='value-title' title='2010-12-16T00:00:00-08:00'/>
</time/>
<a href="/users/25?page_id=25" class="fancy-ajax logo">
  <span/>
  <img alt="Logo for Heavenly Cleaning" class="photo" src="/images/41/name-logo-small.JPG?1297971958" title="Logo for Heavenly Cleaning" />
</a>
<a href="/pages/25/bookmarks" class="status bookmark">Like</a>
</figure/>
...

I am returning it as a json string and appending it like this:

$(window).load(function() {
  var params = paginator;
  params.dataType = "string";
  $('#content').pageless({
    url: window.location.pathname,
    params:      params,
    distance:    500,
    totalPages:  10,
    loaderImage: "/images/loaders/load.gif",
    scrape: function(data) {
      var data      = $.parseJSON(data);
      var paginator = data.paginator;
      var search    = data.search;
      var html      = data.pages // html string;

      if (data.more == false) {
        $.pageless.settings.totalPages = $.pageless.settings.currentPage;
        if($.pageless.settings.totalPages <= $.pageless.settings.currentPage){
          $.pageless.stopListener();
        }
      }

      $.pageless.settings.params = {dataType: "string", paginator: paginator, q: search.q, c: search.c, l: search.l, a: search.a};

      return html;
    }
  });
})


Since you're using HTML5 elements, I assume you're using HTML5Shiv or Modernizr to hack IE to support those elements?

If not then yes, you will definitely have issues, since IE6/7/8 will simply not recognise those tags as valid HTML.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜