Jquery sparkline does not work when loading remote HTML content

To speed the load time for a page on my site I use jquery to load a remote page that contains usage statistics and a usage chart.

By allowing the primary page to load first - and then loading the stats content separately I was able to dramatically reduce the primary page load time - improving user experience.

The page's initial design loaded the stats content in line and displayed one of the elements using sparkline.js:
class="sparkline" data-values="1,2,3"

The problem was that when I loaded this content using:

The sparkline js wasn't applying to the remotely loaded content. The solution was to fire the sparkline JS again after the content was loaded:
By applying the sparkline js function after successful load, the sparkline appeared just fine on the HTML loaded sparkline data.
Happy coding.

No comments:

Post a Comment