question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to reload when updating pages with ajax?

See original GitHub issue

I’m using turbolinks to change pages without reloading css/js: https://github.com/rails/turbolinks

This project works great but doesn’t run again when I change “pages”. I’ve tried setting all my .adunit html to blank to remove the ads, but the .dfp code still doesn’t seem to let me run it again.

$('.adunit').html('')

Here’s how they do it for google adsense: http://reed.github.io/turbolinks-compatibility/google_adsense.html

Any suggestions please? Great project!

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zrishercommented, Jul 22, 2014

Another note for anyone having issues getting this plugin to work with turbolinks:

Make sure you’re using data-adunit="dfp_ad_code" instead of id="dfp_ad_code" to specify the ad slot identifier.

The latter won’t work (probably something about jquery trying to access a dom object that’s gone). I read through all the above and couldn’t figure out why it wasn’t working for me. After copying the example verbatim into my app, this turned out to be the culprit.

0reactions
inspire22commented, Apr 10, 2013

Just another note, this library causes some issues with

https://github.com/kossnocorp/jquery.turbolinks

because of how init uses jquery.ready to delay calling createAds()

$(function () { createAds(options); });

Jquery.turbolinks automatically detects jquery.ready calls and adds them to a call stack to be called each page - so it gets called 2 times on page 2, 3 times on page 3, etc.

I just rewrote my code to not rely on this library as it was pretty easy to do away with given how I’ve organized my code so far.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reload the page after ajax success - Stack Overflow
Using the ajaxSuccess to reload the page after ajax success. $(document).ajaxSuccess(function(){ window.location.reload(); });.
Read more >
Reload or Refresh a Page after Ajax Success using jQuery
You can use the location.reload() method to reload or refresh an entire web page or just the content inside an element. The .reload()...
Read more >
AJAX Introduction - W3Schools
AJAX is about updating parts of a web page, without reloading the whole page. ... AJAX is a technique for creating fast and...
Read more >
How to Refresh Page Using JavaScript & jQuery - JS-Tutorials
We will use JavaScript methods to reload the page and refresh the page. The jQuery AJAX is also used to refresh the page....
Read more >
Refresh page after posting data to server via Ajax
I was trying to make the refresh occur after a successful POST but it doesn't happen. The POST occurs from a page with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found