Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@ryangjchandler/alpine-parent
Advanced tools
Adds a handy $parent magic property to your Alpine components.
✨ Help support the maintenance of this package by sponsoring me.
$parent
Access parent components using a handy $parent
magic variable.
This package only supports Alpine v3.x.
This plugin provides a new $parent
magic property that allows you to interact with a parent component's data object directly. This is useful when you have nested components and conflicting property names but would still like to access the parent properties / methods directly.
Include the following <script>
tag in the <head>
of your document, just before Alpine.
<script
src="https://cdn.jsdelivr.net/npm/@ryangjchandler/alpine-parent@1.x.x/dist/cdn.min.js"
defer
></script>
npm install @ryangjchandler/alpine-parent
Add the $parent
directive to your project by registering the plugin with Alpine.
import Alpine from "alpinejs";
import Parent from "@ryangjchandler/alpine-parent";
Alpine.plugin(Parent);
window.Alpine = Alpine;
window.Alpine.start();
Access the $parent
property in your component:
<div x-data="{ value: 'foo }">
<div x-data="{ value: 'bar' }">
My value is <span x-text="value"></span> and my parent's value is <span x-text="$parent.value"></span>
</div>
</div>
The $parent
property returns a Proxy
, so any updates to the properties should be reactive. This means you'll be able to use it inside of x-model
, etc.
This projects follow the Semantic Versioning guidelines.
Copyright (c) 2021 Ryan Chandler and contributors
Licensed under the MIT license, see LICENSE.md for details.
FAQs
Adds a handy $parent magic property to your Alpine components.
The npm package @ryangjchandler/alpine-parent receives a total of 63 weekly downloads. As such, @ryangjchandler/alpine-parent popularity was classified as not popular.
We found that @ryangjchandler/alpine-parent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.