How to reload when updating pages with ajax?
See original GitHub issueI’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:
- Created 10 years ago
- Comments:12 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another note for anyone having issues getting this plugin to work with turbolinks:
Make sure you’re using
data-adunit="dfp_ad_code"
instead ofid="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.
Just another note, this library causes some issues with
because of how init uses jquery.ready to delay calling createAds()
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.