![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
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.
ember-bind-helper
Advanced tools
This addon provides a bind
helper to bind a function to a context.
If you are running Ember 3.4+, just ember install ember-bind-helper
.
If you are running a version older than 3.4, do ember install ember-bind-helper@0.3.2
instead.
bind
Let's say we want to call a method of an object when we click a function. We might think of doing the following:
<button onclick={{action myObject.myMethod}}>
My Button
</button>
Sadly, this might not work as expected, given that the context would be the
controller
(twiddle).
To solve this, you can use the bind
helper:
<button onclick={{bind myObject.myMethod}}>
My Button
</button>
This automagically sets the context to myObject
. If the method were myObject.mySubobject.myMethod
it would
bind it to myObject.mySubobject
and so on. The only exception to this rule is that if the last part of the chain
before the method name is actions
, it gets removed too:
<button onclick={{bind myObject.actions.myMethod}}>
My Button
</button>
This sets the context to myObject
. Normally it would have been myObject.actions
but, given the last part is actions
,
ember-bind-helper removes that too leaving only myObject
.
You can explicitly set the target by adding a named argument target
:
<button onclick={{bind myObject.mySubobject.myMethod target=myObject}}>
My Button
</button>
bind
also passes any extra parameters to the binding function. Thus, when we click this button:
<button onclick={{bind myMethod 1 2 3 "caramba"}}>
My Button
</button>
myMethod
will receive 1
, 2
, 3
and "caramba"
as arguments.
npm run lint:hbs
npm run lint:js
npm run lint:js -- --fix
This project is licensed under the MIT License.
FAQs
Ember bind helper helps you bind functions in your templates.
The npm package ember-bind-helper receives a total of 59 weekly downloads. As such, ember-bind-helper popularity was classified as not popular.
We found that ember-bind-helper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.