First of all , thakn you so much for the sample code here and got me to understand better :)
I ran into a bug here, so the updating the field works but then the error below showed up in the console and the text field became disabled. And after updating with the new value, the new value is not displaying (so the old value is still showing)
I did modified a bit on the livewire component. I am not sure where I did wrong here. Appreciate any help if you are available. Thanks
SupportAlpine.js:315 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'split') at beforeAlpineTwoPointSevenPointThree (SupportAlpine.js:315) at isHiding (SupportAlpine.js:299) at alpinifyElementsForMorphdom (SupportAlpine.js:274) at onBeforeElUpdated (index.js:479) at callHook (morphdom.js:35) at morphEl (morphdom.js:199) at morphdom.js:332 at morphEl (morphdom.js:219) at morphdom.js:463 at Component.value (index.js:386)
profile-mobile.php
`class ProfileMobile extends Component
{
public $origData;
public $newData;
public $isData;
public $userid;
public $field;
public function mount(User $user,$field) {
Log::info('profile-mobile'. $user);
$this->userid = $user->id;
$this->field = $field;
$this->origData = $user->{$field};
Log::info ('Old Data '. $this->origData);
$this->init($user);
}
public function init(User $user) {
//$this->origData = $user->{$this->field} ?: $this->userid;
$this->origData = $user->{$this->field};
Log::info('updated clear '. $this->origData);
$this->newData = $this->origData;
$this->isData = $user->{$this->field} ?? false;
}
public function save()
{
$user = User::find($this->userid);
$newd = trim($this->newData);
$user->{$this->field} = $newd ?? null;
$user->save();
$this->init($user);
}
public function render()
{
return view('livewire.profile-mobile');
}
First of all , thakn you so much for the sample code here and got me to understand better :) I ran into a bug here, so the updating the field works but then the error below showed up in the console and the text field became disabled. And after updating with the new value, the new value is not displaying (so the old value is still showing)
I did modified a bit on the livewire component. I am not sure where I did wrong here. Appreciate any help if you are available. Thanks
SupportAlpine.js:315 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'split') at beforeAlpineTwoPointSevenPointThree (SupportAlpine.js:315) at isHiding (SupportAlpine.js:299) at alpinifyElementsForMorphdom (SupportAlpine.js:274) at onBeforeElUpdated (index.js:479) at callHook (morphdom.js:35) at morphEl (morphdom.js:199) at morphdom.js:332 at morphEl (morphdom.js:219) at morphdom.js:463 at Component.value (index.js:386)
profile-mobile.php
`class ProfileMobile extends Component { public $origData; public $newData; public $isData; public $userid; public $field;
} ` and the view component:
`<div x-data=" { isEditing: false, isData: '{{ $isData }}', focus: function() { const textInput = this.$refs.textInput; textInput.focus(); textInput.select(); } } " x-cloak