datepicker update results on close/type error

331
3
Jump to solution
12-27-2017 07:02 AM
FranklinAlexander
Occasional Contributor II

I have recently updated a web app to WAB 2.4 that pulls black bear sighting data from a server when queried. The query widget has 7 parameters with which to filter results, two of which are a start date and end date. I am using the jquery datepicker for the dates, but I want the app to automatically update the results when the calendar is closed. I already have an "onchange:" event set in the widget html, which works fine for the other parameters, but not with the datepicker. I have been trying to use the onClose method from within the datepicker object to search the database and update the results when the calendar is closed, but when I try and call a function that has been defined outside of the $(document).ready(function), I get a type error: 'this._BBearFetch is not a function'. I am fairly sure this is a scope issue, but I cannot figure out how to solve this. The function I am trying to call is defined as a value in the clazz object, and I located the datepicker in the startup: function(). I hope this makes sense, but I have attached a code snippet for more clarity. Thanks for any advice, I am sure I am missing something obvious. 

0 Kudos
1 Solution

Accepted Solutions
FranklinAlexander
Occasional Contributor II

Got it working.The problem seemed to be that it was buried too deeply inside 3 tiers of functions. I created a function called _datepicker in the clazz object containing the datepicker jquery code, then referenced it in the startup function. I also think that being inside the $(document).ready(function) was causing some scope issues, so I am not using it.    

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Franklin,

   It definitely is a scope issue but I don't use jQuery in widgets and not inline functions like that so the best I can do is take a educated guess at the resolution.

                    onClose: lang.hitch(this, function(newDate, datepicker){
                        if($(this).data('previous' != newDate)){
                            this._BBearFetch();
                        }
                    })
0 Kudos
FranklinAlexander
Occasional Contributor II

Thanks Robert. I am still getting the same error, but I think you are on the right track and at least it puts me on the right path! 

0 Kudos
FranklinAlexander
Occasional Contributor II

Got it working.The problem seemed to be that it was buried too deeply inside 3 tiers of functions. I created a function called _datepicker in the clazz object containing the datepicker jquery code, then referenced it in the startup function. I also think that being inside the $(document).ready(function) was causing some scope issues, so I am not using it.