| 1234567891011121314151617181920212223 |
- import { Controller } from '@hotwired/stimulus';
- import { visit } from '@hotwired/turbo';
- export default class extends Controller {
- static values = {
- url: { type: String, default: '/changeview' }
- }
- change(event) {
- event.preventDefault();
- fetch(this.urlValue)
- .then((response) => {
- if (!response.ok) {
- throw new Error(`Erreur Http : ${response.status}`);
- }
- return response.json();
- })
- .then(() => {
- visit(window.location.href, { action: 'replace' });
- })
- }
- }
|