leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

'wice_grid.js not loaded' message in development environment conflicts with other onload functions #196

Closed wubr closed 9 years ago

wubr commented 9 years ago

I'm running into an instance where the development environment 'wice_grid.js is not loaded...' message from wice_grid_view_helpers.rb:464-473 is overriding an otherwise completely separate window.onload function set earlier in the page.

A configuration option to withhold the message or other code change to allow other onloads to co-exist would be helpful.

leikind commented 9 years ago

Sorry, I understood nothing.

Can you please say exactly what message you see, where, when. Versions of Rails and WiceGrid are also appreciated. Stacktraces are welcome

wubr commented 9 years ago

Apologies, I'll try to be clearer:

wice_grid 3.4.2 - and rails 4.2.0, Ruby 2.2.0.

https://github.com/leikind/wice_grid/blob/rails3/lib/wice/helpers/wice_grid_view_helpers.rb#L497-L506

When running in development, the linked code inserts into the rendered page a function assignment to window.onload which interferes with external pre-existing assignments of window.onload.

In my case, I'm using lazy_high_charts (1.5.4) on the same page I'm putting a wice_grid on, and because wice_grid's window.onload is present it is preventing the charts' window.onload from being run and the charts do not appear.

It's a helpful message when wice_grid isn't installed properly, but it would be nice if I could disable it once I don't need the reminder. If there's a different way to make the window.onloads play nicely together I'd probably be for that too.

leikind commented 9 years ago

You are right. This piece of code has been there since Rails 2 pre-jquery times (yes, WiceGrid is that old).

Thank you for you report, I will replace it by $(document).ready

leikind commented 9 years ago

check version 3.4.12 out

wubr commented 9 years ago

Looks good - thanks!