I get this javascript error "Uncaught TypeError: Object #
has no method 'datepicker'".
According to file "better_exposed_filters_exposed_form_plugin.inc" js file "better_exposed_filters.js" can be included in two cases
first case: better_exposed_filters_exposed_form_plugin.inc line 867
We adding BEF's JavaScript to the mix to handle select all/none functionality
second case: better_exposed_filters_exposed_form_plugin.inc line 922
We adding Datepicker JS and CSS.
And according to line 918 we always have "bef_datepicker" js setting for each view, if we have exposed filter.
Default it set on FALSE. But if variable $add_datepicker is TRUE, we set "bef_datepicker" on TRUE and include Datepicker library(ui.datepicker) and include js "better_exposed_filters.js".
Next, if we need ajax render page with several views with exposed filters, "bef_datepicker" setting becomes array of boolean values(NOTE! It possible with AJAX render only).
I get situation with rendering 5 views, when "better_exposed_filters.js" was included on line 867, but "$add_datepicker" variable was false 5 times, and "bef_datepicker" setting becomes array of 5 false values.
So I get included "better_exposed_filters.js" without included Datepicker library!
Next, if "better_exposed_filters.js" is included, it check "bef_datepicker" setting on line 86.
Array of false values casts in TRUE. So next javascript check "bef_dateformat" and then try to apply method "datepicker" to "bef-datepicker" class, and get error, because "Datepicker" library is not included, and "datepicker" method is not available.
So I propose additional check on "bef_dateformat".
According to "better_exposed_filters_exposed_form_plugin.inc" 921-928 lines "bef_dateformat" always is defined if "Datepicker" library was included.
So checking "bef_dateformat" on "undefined" value is sufficient condition.
Sorry for my English
Comments
Comment #2
andyposttrailing whitespace!
Comment #3
kalistos commentedwhitespaces trimmed
Comment #5
andypostIt looks that tests are broken. We have no JS testing for now anyway
makes sense because this settings variable could be undefined
Comment #6
kalistos commentedComment added
Comment #7
gynekolog commented#6 works, thank you.
Comment #8
maximpodorov commentedComment #9
andypost@maximpodorov we have 3 reviews and no JS testing, so back to rtbc
Comment #10
kehan commentedIndeed the patch works for me too
Comment #11
sgabe commentedI can confirm that the patch in #6 applies and works fine!
Comment #12
mikeker commentedCommited.
Thanks!
Comment #14
maximpodorov commentedCurrently, BEF won't show datepickers. Additional patch is needed.
Comment #15
kalistos commentedComment #16
maximpodorov commentedOne more check is needed. Please apply this patch and the patch from #1961486: Latest dev release + slider breaks views UI javascript since incorrect JavaScript breaks many things, including Rules UI.
Comment #17
maximpodorov commented@mikeker
Please apply this simple fix.
Comment #18
mikeker commentedThe underlying problem was that the BEF settings being set in the plugin had gotten out of sync with what was expected in BEF's JS code. An adapted version of your patch was committed along with a major revamping of the automated tests for this project.
Comment #20
markusk commentedHave to reopen the issue as it still persists in 7.x-3.0-beta4+6-dev. Same JS error is thrown when you use a BEF enabled view.
Very annoying side effect: a single view with BEF enabled makes VBO actions in Rules unusable as it breaks Rules' UI. Had to disable BEF because of that.
Comment #21
tisteegz commentedI am also having a datepicker issue. I am currently on 7.x-3.0-beta4 and cannot use my view with Ajax enabled otherwise I get the following error.
Uncaught TypeError: Cannot read property 'dateformat' of undefined.
Even though I am not using Dates at all.
Comment #22
donutdan4114 commentedI have this issue as well:
Uncaught TypeError: Cannot read property 'dateformat' of undefined.I don't have anything that requires a date picker in my view...
Comment #23
firfin commentedSame error here. Strange to notice I couldn't go to the BEF settings in my views page display (although it worked on the master display) so it wasn't possible to re-save these settings.
Workaround for me was reverting to beta3. No problems then.
Comment #24
maximpodorov commentedThis patch adds datepicker library existence check.
Comment #25
firfin commentedAplying the patch cleared up the error message about 'datepicker'.
Also it seems sensible to have this check in place anyway.
However, I get another error after applying the patch ( ' Uncaught TypeError: Cannot read property 'length' of undefined' ) I hoped this would be easily fixed by disabling 'jQuery update' module, and then the BEF settings worked as expected. Unfortunately this wasn't the case.
thanks for a valiant effort @maximpodorov !
Comment #26
maximpodorov commentedWhere do you get ' Uncaught TypeError: Cannot read property 'length' of undefined' error?
Comment #27
legittalon commentedI've updated this patch to also fix the jQuery 'Uncaught TypeError: Cannot read property 'length' of undefined' error. Now AJAX stuff inside views should work properly
Comment #28
firfin commentedPatch from #27 @legittalon works for me (with beta 4). No more errors.
Updating status.
Comment #29
firfin commentedComment #30
maximpodorov commentedWhy do you mix slider and datepicker? There is another issue related to slider: #1961486: Latest dev release + slider breaks views UI javascript.
Comment #31
firfin commentedSorry bout the mix up @maximpodorov I just know the patch provided in #27 solved my problems (or at least seems to).
Comment #32
TravisJohnston commentedI tried the patch in #27 with no luck. I am having a similar problem when I try to load View Bulk Operations into Rules, when I go to create an Action Set, and click Add Action and choose the "Load a list of entity..." (either one of the 2 that show) the "please wait" toggle starts spinning then nothing happens.
Looking at the console log I see this:
Uncaught TypeError: Cannot read property 'dateformat' of undefined
Source is from VM788 line 198 typeof Drupal.settings.better_exposed_filters.datepicker_options.dateformat !== 'undefined') {
I tried updating BEF to latests dev branch, applied the patch in #27, but that didn't work.
Comment #33
alex.druhetHere is a simple workaround that can bring your filters back: just use the 7.x-3.0-beta3 version of better_exposed_filters.js. As a temporary hack, add it to template.php in your theme with hook_js_alter :
Comment #34
TravisJohnston commentedHey Alex,
Thanks for your reply. I did was you said and swapped out the js file with the newest 7.3 beta, (and cleared caches), and I am still getting a spinning wheel that just stops and nothing happens. Console still says the dateformat is undefined.
UPDATE: Hold on, I just checked the Sources log, and it's still loading the modules JS instead of the one in my theme.
Comment #35
TravisJohnston commentedHey Alex,
For the heck of it, to not waste time looking at why my version of the JS didn't load, I replaced the code in the current JS file with the new one and tried that. Still no change, same dateformat error. Am I missing a step? I am still using the latest Dev branch for the core module files. It's still having trouble with the following undefined:
Comment #36
ufku commentedFixed the usage of Drupal.settings.better_exposed_filters.
Comment #37
bendev commented#36 works as expected.
thanks
Comment #38
plazik commented#36 works on dev version for me too.
Thanks.
Comment #39
mikeker commentedThanks, everyone, for your patience on this issue.
The fix in #36 has been committed.