How do i empty an input field after post have been created

What seems to be the problem:

After data have been stored/created in the database i want to empty the input field.

Steps to Reproduce:
The screenshot below contains the process

image

what i tried doing

image

I get this error in my browser console after data have been created.

The text input doesn’t get empty.
image

Are you using the latest version of Livewire:

Yes

Do you have any screenshots or code examples:
Added above

1 Like

I don’t think your problem is in that line. That should work fine. There is something that breaks your js and as a result it doesn’t carry on to empty the content. I don’t have enough information though to see what that bug is.

1 Like

Does your textarea have an actual name attribute?

1 Like

No, none at all…

<textarea style='height: 10%; padding-right: -23px;' wire:model="content" class="form-control" placeholder="What’s on your mind"></textarea>

here is a screenshot of the line throwing me an error in my console…

I’m suggesting that you might need a name?

I added that it’s still the same issue

1 Like

Can you post the entire contents of your Blade view? These errors usually happen when the dom-diffing can’t keep track of elements because of a top level conditional in Blade.

Read this page for more info as well: https://laravel-livewire.com/docs/troubleshooting/

here is the file

Profile picture
                        <a>
                            <span class="badge badge-secondary" id="imageIcon">
                                <img  src="{{asset('img/camera.png')}}" class="img-fluid" alt="icon" style="width: 11px;">
                        </a>
                        <a>
                            <span class="badge badge-secondary" id="locationIcon">
                                <img src="{{asset('img/location.png')}}" class="img-fluid" alt="icon" style="width: 11px;">
                            </span><span id="locationData" style="font-size: 12px;"></span>
                        </a>
                       <input type="hidden" wire:model="location" id="locationPost">
                            {{--  <input type="hidden" id="userId" wire:model="user_id" value="{{Auth::user()->id}}" />  --}}
                        <input style="display:none" accept=".png, .jpg, .jpeg"  multiple type="file"  id="addPhotos"  />
            
                        <button  wire:loading.attr="disabled" wire:click="addPost" class="btn btn-info btn-add pull-right" style="float: right">Post</button>
                    </div>
                </div>
                <span id="displayImage"></span>
               
            </div>
        </div>
    </div>
</div>

I am using a single (page ) component.
livewire spa mode

private function ClearVars() {
$this->post[‘title’] = null;
# $this->title= null;
$this->post[‘body’] = null;
# $this->body= null;
}
#call ClearVars() to use
#this->content
this->ClearVars()

#WhatIKnowIDoNotKnow