leikind / wice_grid

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

Strange behavior of datetime picker #285

Closed webchi closed 8 years ago

webchi commented 8 years ago

Using wice_grid in smartadmin wrapbootstrap theame. When opening page with grid there is no icon of small calendar for date select. When again click on contacts_path link than 4 icons of them are appearing. If I continue to click on the link to the number of icons increasing uncontrollably. Is it a bug? Or feature? 11

leikind commented 8 years ago

If this happens with some theme then obviously something messes up with the way WiceGrid's CSS/JS work. Try removing that theme and see if the problem persists

webchi commented 8 years ago

Try removing that theme and see if the problem persists

It's impossible. Better find out why wice_grid javascript not initialize on first boot of the page. And only work from second clicking.

joelw commented 8 years ago

I've found that this sort of thing happens if you call the initWiceGrid() function multiple times, which can happen once you start doing fancy things with reloading bits using Ajax and so on.

It would be possible to modify the function to detect if it has been run already.. I have hacked this up in my application by doing something like the following, which literally just checks to see if the jquery datepicker icon is present.

      if (($('.date-filter.wg-jquery-datepicker i').length > 0) || (document.readyState != "complete")) {
        return;
     } else {
        initWiceGrid();
     }

If you're not manually calling initWiceGrid() and it's getting triggered by WiceGrid's own loading function, it would be better to do something like add a new class variable that records whether it has been initiated already.

webchi commented 8 years ago

Funny that the number of icons is stored until you go to other links and continue grow up when you get back to grid page. After refreshing by F5 all are dissapearing.

Yep... problem in turbolinks. When turn them off then no new icons were generated.