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.
Solved! Go to Solution.
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.
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();
}
})
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!
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.