michelson/lazy_high_charts — pull request #95 by fred (2012-12-16 14:38:37+00:00)
Title: Turbolinks support

Hi,
What do you think about adding support for turbolinks? https://github.com/rails/turbolinks

the issue is that window.onload does not work with turbolinks,

```javascript
(function() {
var onload = window.onload;
window.onload = function(){
if (typeof onload == "function") onload();
#{core_js}
};
})()
```

so I this works instead

```javascript
(function() {
$(window).bind('page:load', function() {
#{core_js}
});
})()
```

well, it's jquery... I could not yet get it in pure javascript yet.
Any clues anyone how to do it in javascript only?

anyways, in the method build_html_output, I changed to this:

```ruby
if defined?(request) && request.respond_to?(:xhr?) && request.xhr?
graph =<<-EOJS

EOJS
elsif defined?(Turbolinks)
graph =<<-EOJS

EOJS
else
graph =<<-EOJS

EOJS
end
```

I don't think it's clean, only enough to give you the idea.

what you guys think?