[BUGFIX] js errors
This commit is contained in:
		| @@ -20,46 +20,51 @@ document.addEventListener('DOMContentLoaded', function() { | |||||||
|  |  | ||||||
| function selectBoatChange() { | function selectBoatChange() { | ||||||
|   const boatSelect = <HTMLSelectElement>document.querySelector('#boat_id'); |   const boatSelect = <HTMLSelectElement>document.querySelector('#boat_id'); | ||||||
|   const boatChoice = new Choices(boatSelect, { |  | ||||||
|     loadingText: 'Wird geladen...', |  | ||||||
|     noResultsText: 'Keine Ergebnisse gefunden', |  | ||||||
|     noChoicesText: 'Keine Ergebnisse gefunden', |  | ||||||
|     itemSelectText: 'Zum Auswählen klicken', |  | ||||||
|     callbackOnCreateTemplates: function () { |  | ||||||
|       return { |  | ||||||
|           option: ({ label, value, customProperties, active, disabled, }: any) => { |  | ||||||
|               const opt: HTMLOptionElement = Choices.defaults.templates.option.call( |  | ||||||
|                   this, |  | ||||||
|                   { label, value, customProperties, active, disabled } |  | ||||||
|               ); |  | ||||||
|  |  | ||||||
|               // We get the original <option> from choicejs |   if(boatSelect) { | ||||||
|               const originalOption: HTMLOptionElement = this._presetOptions.filter( |     const boatChoice = new Choices(boatSelect, { | ||||||
|                   (option: HTMLOptionElement) => option.value === value |       loadingText: 'Wird geladen...', | ||||||
|               )[0]; |       noResultsText: 'Keine Ergebnisse gefunden', | ||||||
|  |       noChoicesText: 'Keine Ergebnisse gefunden', | ||||||
|  |       itemSelectText: 'Zum Auswählen klicken', | ||||||
|  |       callbackOnCreateTemplates: function () { | ||||||
|  |         return { | ||||||
|  |             option: ({ label, value, customProperties, active, disabled, }: any) => { | ||||||
|  |                 const opt: HTMLOptionElement = Choices.defaults.templates.option.call( | ||||||
|  |                     this, | ||||||
|  |                     { label, value, customProperties, active, disabled } | ||||||
|  |                 ); | ||||||
|    |    | ||||||
|               const rowers = Number(originalOption.dataset.amount_seats) - 1; |                 // We get the original <option> from choicejs | ||||||
|  |                 const originalOption: HTMLOptionElement = this._presetOptions.filter( | ||||||
|  |                     (option: HTMLOptionElement) => option.value === value | ||||||
|  |                 )[0]; | ||||||
|                  |                  | ||||||
| 	      setMaxAmountRowers(rowers); |                 const rowers = Number(originalOption.dataset.amount_seats) - 1; | ||||||
|  |                  | ||||||
|  |           setMaxAmountRowers(rowers); | ||||||
|                  |                  | ||||||
|            |            | ||||||
|               return opt; |                 return opt; | ||||||
|           } |             } | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|     } |     } as any); | ||||||
|   } as any); |  | ||||||
|    |    | ||||||
|   choiceObjects[boatSelect.id] = boatChoice; |     choiceObjects[boatSelect.id] = boatChoice; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   const shipmasterSelect = <HTMLSelectElement>document.querySelector('#shipmaster'); |   const shipmasterSelect = <HTMLSelectElement>document.querySelector('#shipmaster'); | ||||||
|   const shipmasterChoice = new Choices(shipmasterSelect, { |   if(shipmasterSelect) { | ||||||
|     loadingText: 'Wird geladen...', |     const shipmasterChoice = new Choices(shipmasterSelect, { | ||||||
|     noResultsText: 'Keine Ergebnisse gefunden', |       loadingText: 'Wird geladen...', | ||||||
|     noChoicesText: 'Keine Ergebnisse gefunden', |       noResultsText: 'Keine Ergebnisse gefunden', | ||||||
|     itemSelectText: 'Zum Auswählen klicken', |       noChoicesText: 'Keine Ergebnisse gefunden', | ||||||
|   }); |       itemSelectText: 'Zum Auswählen klicken', | ||||||
|  |     }); | ||||||
|      |      | ||||||
|   choiceObjects[shipmasterSelect.id] = shipmasterChoice; |     choiceObjects[shipmasterSelect.id] = shipmasterChoice; | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| function setMaxAmountRowers(rowers: number){ | function setMaxAmountRowers(rowers: number){ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Marie Birner
					Marie Birner