iamnoah / writeCapture

Utility to assist the Ajax loading of HTML containing script tags that use document.write. Mailing List: http://groups.google.com/group/writecapturejs-users
http://iamnoah.github.com/writeCapture
Other
241 stars 38 forks source link

Using writeCapture to change ads through a gallery #37

Closed oweichselbaum closed 13 years ago

oweichselbaum commented 13 years ago

Hi,

I'm trying to use your writeCapture library, so when I click to the next image my div with the ads refresh, except they also display every ad in the cycle.

My test js being used in the console:

var innerhtml = jQuery('#sidebar_ad').html(); jQuery('#sidebar_ad').writeCapture().html(innerhtml);

Again, this does refresh the ads, but instead of displaying 2 ads, which is what it's supposed to do, it displays 8 ads, which are all part of that cycle.

The ads can be viewed on the right rail at: http://stage.youbeauty.com/hair/galleries/celebrities-with-black-hair

Except the plugin is not yet on that site, only on my local site.

Any ideas/help would be appreciated.

Thanks, Oren

iamnoah commented 13 years ago

When you make this call:

 jQuery('#sidebar_ad').html()

You get all the script tags currently in that element. That means you get the script that loaded the ad as well as any scripts it wrote.

You need to give writeCapture the clean, uninterpreted HTML.