Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Livewire - @this.set/Livewire.emit clearing input value using isMobile #550

Open
GamendeBrian opened this issue Jun 16, 2023 · 1 comment

Comments

@GamendeBrian
Copy link

I'm using the newest version of Livewire (2.12.3) and Air Datepicker (3.3.5).

At the moment I'm trying to set 2 global variables (date_from & date_to) in my Livewire controller.

Everything is working perfectly fine when using @this.set('date_from', date) OR Livewire.emit('updateDate', 'date_from', formattedDate) when isMobile is false.

See the code snippet here:

      {
        ...defaultOptions,
        isMobile: true,
        onSelect({date, datepicker, formattedDate}) {
          date_to_big_truck_mobile.update({
            minDate: date
          })
          if(date_to_big_truck_mobile.$el.value) {
            if(moment(date_to_big_truck_mobile.$el.value, 'DD-MM-YYYY').isBefore(date)) {
              date_to_big_truck_mobile.selectDate(date)
            }
          } else {
            date_to_big_truck_mobile.selectDate(date)
          }
          @this.set('date_from', formattedDate);
          // OR THIS
          Livewire.emit('updateDate', 'date_from', formattedDate)
        },
      }

As you can see I'm tryin to set the date_from var while isMobile: true.
What happens now:

airdatepicker-is-mobile-on

The input is being cleared, but as you can see with the string that is showing up, it does set.

And when I do isMobile: false, it works perfectly fine.

airdatepicker-is-mobile-off

Is there a different way I should approach when using isMobile in combination with Livewire?
Or should I expect a fix for the isMobile prop?

Thanks!

@GamendeBrian GamendeBrian changed the title Livewire - Emit/@set resetting clearing value in input after 1 sec using isMobile = true Livewire - Emit/@setclearing input value using isMobile = true Jun 16, 2023
@GamendeBrian GamendeBrian changed the title Livewire - Emit/@setclearing input value using isMobile = true Livewire - @this.set/Livewire.emit clearing input value using isMobile Jun 16, 2023
@GamendeBrian
Copy link
Author

Temporary fix:
I added a value attribute to the inputs and set it to echo the $date_from & $date_to variables.

Example:
<input value="{{ $date_to ?? '' }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant