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

Error message for jQuery datepicker even though I'm using Bootstrap datepicker #223

Closed Nickk4 closed 9 years ago

Nickk4 commented 9 years ago

I'm trying to install the wice_grid gem. In the initializer I've set: Wice::Defaults::HELPER_STYLE = :bootstrap to use bootstrap datepicker. Also, I've included gem 'bootstrap-datepicker-rails' in the Gemfile, *= require bootstrap-datepicker3 in application.css, //= require bootstrap-datepicker in application.js, and I've restarted the server.

However, when visiting the grid that I've created on the development server, I get the pop-up message: "Seems like you do not have jQuery datepicker (http://jqueryui.com/demos/datepicker/) installed. Either install it or set Wice::Defaults::HELPER_STYLE to :standard in wice_grid_config.rb in order to use standard Rails date helpers". In addition to the error message, it doesn't show any filters for date variables.

The error message is correct that I've not installed jQuery datepicker because I want to use Bootstrap datepicker. But why is it still looking for jQuery datepicker while I've set the configuration for Bootstrap? And why is it not showing the filters?

leikind commented 9 years ago

are you using the latest from github?

Let's debug it

  1. Please post here the output of $.fn.datepicker in your browser JS console.
  2. Please say which of these return anything or not in your browser JS console:
    • $('.wice-grid-container .date-filter input:hidden)
    • $('.wg-detached-filter .date-filter .date-filter input:hidden')
    • $('.wice-grid-container input:text[data-provide=datepicker]')
    • $('.wg-detached-filter input:text[data-provide=datepicker]')
Nickk4 commented 9 years ago

Just learning how to program, so I hope I'm following you're instructions correctly.

I'm using gem 'wice_grid', '3.4.14' in my gemfile, so I belief this is the latest version.

I use byebug for debugging. I added debugger at the top of the grid view. If I enter in the debugger fn.datepicker it says *** NameError Exception: undefined local variable or method 'fn' for #<#<Class:0x00000005078898>:0x0000000505b608>. So, I guess this is not what you're asking?

I'm using Firefox. In Firexox I go to Tools > Web developer > Web console.

Does this help?

leikind commented 9 years ago

3.4.14 doesn't have proper support for Bootstrap datepicker. You are using version 3.4.14 and reading documentation on Github for a non-released version. Bootstrap Datepicker support is new (and probably not 100% finished). That explain all your problems. You should either use the unstable (!) and unreleased sources from Github, or read the documentation for 3.4.14. That is, either inside the gem or here: https://github.com/leikind/wice_grid/tree/3.4.14 Mind that even though bootstrap datepicker is mentioned on that page, to use bootstrap datepicker with 3.4.14 you have to set it up manually with javascript. And 3.4.14 has no idea of what Wice::Defaults::HELPER_STYLE = :bootstrap is.

I should probably keep all my development in a separate branch so that the trunk coincides with the latest released versin, so that is partially my fault too.

I use byebug for debugging.

I don't know what that is, probably because I launch Firefox once in a while only for testing purposes

I'm using Firefox. In Firexox I go to Tools > Web developer > Web console.

Yes, this is what you should use

If I enter in the debugger fn.datepicker

NO! $.fn.datepicker , not fn.datepicker

But it doesn't matter already. I've explained your problem above

Please always include version info into your bug reports, will save you some time.

leikind commented 9 years ago

I will close this report because this is not a bug, but should you have questions, post them anyway

Nickk4 commented 9 years ago

Thanks!

Nickk4 commented 9 years ago

I've tried to update to the non-released version.

The error pop-up message however remained. I'm problably not correctly installing the non-released version?

leikind commented 9 years ago

what does $('.wice-grid-container .date-filter input:hidden') return in the js console?

Nickk4 commented 9 years ago

It returns: Object { 0: <input#grid_f_last_login_fr.form-control.input-sm.check-for-bsdatepicker>, 1: <input#grid_f_last_login_to.form-control.input-sm.check-for-bsdatepicker>, 2: <input#grid_f_created_at_fr.form-control.input-sm.check-for-bsdatepicker>, 3: <input#grid_f_created_at_to.form-control.input-sm.check-for-bsdatepicker>, 4: <input#grid_f_updated_at_fr.form-control.input-sm.check-for-bsdatepicker>, 5: <input#grid_f_updated_at_to.form-control.input-sm.check-for-bsdatepicker>, 6: <input#grid_f_activated_at_fr.form-control.input-sm.check-for-bsdatepicker>, 7: <input#grid_f_activated_at_to.form-control.input-sm.check-for-bsdatepicker>, length: 8, prevObject: Object, 2 more… }

I did now notice though that although the pop-up error message is there, the filter does now seem to work (while previously no filter rendered for date variables). So, it's just that the pop-up shouldn't be there. Any idea why the pop-up is still there?

leikind commented 9 years ago

It returns: Object { 0: <input#grid_f_last_login_fr.form-control.input-sm.check-for-bsdatepicker>, 1:

It does not make any sense. Are you sure?

Any idea why the pop-up is still there?

No.

Are you sure you are using the latest version?

What does $.datepicker return?

Nickk4 commented 9 years ago

About the return of $('.wice-grid-container .date-filter input:hidden'): I'm not sure if you're looking at my edited comment? (the first time I posted it I forget to use the sign to indicate it was code, so that didn't work so the reply you might have gotten by email might be weird.) I am certain of the return in the version of my previous edited comment. It does however show a different return if I first open the filter (I have show_filters: :when_filtered so the filters are not shown by default). After clicking the binoculars, $('.wice-grid-container .date-filter input:hidden') returns: Object { length: 0, prevObject: Object, context: HTMLDocument → stakeholders, selector: ".wice-grid-container .date-filter i…" }.

I'm not sure if I'm using the latest version of the gem. I have in my Gemfile: gem 'wice_grid', git: 'https://github.com/leikind/wice_grid.git', branch: 'rails3' and I have run bundle install as well as bundle update. So I guess I should have the latest version then?

$.datepicker returns: undefined. But the grid renders correctly. It's only that the pop-up is there.

leikind commented 9 years ago

if $.datepicker returns undefined you can't have any datepickers. What you say does not make any sense. Is your app available on the internet?

Nickk4 commented 9 years ago

I'll push the current version to Heroku. Can I send you an email with the address?

leikind commented 9 years ago

Yes, go ahead, my email is in wice_grid.gemspec