Guest User

Untitled

a guest
Oct 21st, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. var $this = $(element);
  2.  
  3. $(async function(){
  4. cal = $this.myCalendar(options);
  5. updateMonth();
  6.  
  7. function loadDisabledDates( id, month, url, done) {
  8. $.getJSON( url, function( data ) {
  9. done(data);
  10. });
  11. }
  12.  
  13. var calendarURL = createCalendarURL(currentId, cal.getMonth());
  14.  
  15. // CALLBACKS
  16. loadDisabledDates(currentId, cal.getMonth(), calendarURL, function (data) {
  17. disableUnavailableDates($this, data, cal.getYear(), cal.getMonth());
  18. });
  19.  
  20. // PROMISES
  21. loadDisabledDatesWithPromise(currentId, cal.getMonth(), calendarURL)
  22. .then(function (data) {
  23. // stuff in here
  24. })
  25. .catch(function (error) {
  26. // stuff with errors here
  27. });
  28.  
  29. // ASYNC / AWAIT
  30. let data;
  31.  
  32. try {
  33. data = await loadDisabledDatesWithPromise(currentId, cal.getMonth(), calendarURL)
  34. } catch (error) {
  35. console.log(error);
  36. }
  37.  
  38. console.log(data)
  39. });
Add Comment
Please, Sign In to add comment