Nesting Components
// wires/ContactUs.bx
class extends="cbwire.models.Component" {
data = {
"showForm": false
};
}
<!--- wires/contactus.bxm --->
<bx:output>
<div>
<bx:if showForm>
<!--- Nested component --->
#wire( name="ContactForm" )#
</bx:if>
<button wire:click="$toggle( 'showForm' )">Toggle form</button>
</div>
</bx:output>
You can also pass parameters.
// wires/ContactUs.bx
class extends="cbwire.models.Component" {
data = {
"showForm": false,
"sendEmail": false,
"validateForm": true
};
function onMount( params ) {
data.sendEmail = params.sendEmail;
data.validateForm = params.validateForm;
}
}
<!--- wires/contactus.bxm --->
<bx:output>
<div>
<bx:if showForm>
#wire(
name="ContactForm"
params={
sendEmail: true,
validateForm: true
}
)#
</bx:if>
<button wire:click="$toggle( 'showForm' )">Toggle form</button>
</div>
</bx:output>
Last updated
Was this helpful?