IPhone Webkit jQuery weirdness: unable to update content

Running into the weirdest issue on iPhone using jQuery using my WebViewController.

I have a div to which I am adding content:

<div id="thumbnails">
  Here are your thumbnails:
  <div id="mythumbs"></div>
</div>

The code looks like this:

for (var i = 0; i < thumbs.length; i++) {
  var item = thumbs[i];
  $('<img class="imgthumb" />').data('url', item.Url).attr({
    "src": item.Thumbnail.Url,
  }).appendTo($('#mythumbs'));
};

It works great.

Then I switch to other divs ( $('#thumbnails').hide(); $('#someotherdiv').show()), keep talking about my business, and ultimately switch back to div thumbnails.

At this moment, I cannot add any content to this div using jQuery. I can delete just fine, but the application no longer works.

The exact same code works fine on Firefox and Safari outside of the iPhone, but once in the embedded WebKit it fails.

If I modify the DOM directly using JavaScript, it works, but if I use jQuery, this will not work:

var x = document.createTextNode('THE FIRST THING');
document.getElementById('thumbspage').appendChild(x);
$('#thumbspage').append('-- THE SECOND THING');

" " , " " .

? .

0
1

:

objective-c, window.location. , setTimeout window.location, . , window.location objective-c, javascript, . setTimeout, javascript , objective-c. - .

+1

Source: https://habr.com/ru/post/1711764/


All Articles