wire:dirty
Basic Usage
// wires/ContactForm.bx
class extends="cbwire.models.Component" {
data = {
"name": "",
"email": "",
"message": ""
};
function submit() {
// Save form data
sleep(1000);
// Form is now synced
}
}// wires/ContactForm.cfc
component extends="cbwire.models.Component" {
data = {
"name" = "",
"email" = "",
"message" = ""
};
function submit() {
// Save form data
sleep(1000);
// Form is now synced
}
}<!-- wires/contactForm.bxm -->
<bx:output>
<form wire:submit="submit">
<input type="text" wire:model="name" wire:dirty.class="border-yellow-500" placeholder="Name">
<div wire:dirty wire:target="name">Name has unsaved changes...</div>
<input type="email" wire:model="email" placeholder="Email">
<textarea wire:model="message" placeholder="Message"></textarea>
<button type="submit">Submit</button>
<div wire:dirty>You have unsaved changes. Click submit to save.</div>
<div wire:dirty.remove>All changes saved!</div>
</form>
</bx:output><!-- wires/contactForm.cfm -->
<cfoutput>
<form wire:submit="submit">
<input type="text" wire:model="name" wire:dirty.class="border-yellow-500" placeholder="Name">
<div wire:dirty wire:target="name">Name has unsaved changes...</div>
<input type="email" wire:model="email" placeholder="Email">
<textarea wire:model="message" placeholder="Message"></textarea>
<button type="submit">Submit</button>
<div wire:dirty>You have unsaved changes. Click submit to save.</div>
<div wire:dirty.remove>All changes saved!</div>
</form>
</cfoutput>What wire:dirty Does
Available Modifiers
Was this helpful?