Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
ember-autofocus
Advanced tools
Readme
##ember-autofocus 0.0.3
Automatically focus on an input field upon page load in Ember
// myView.handlebars
:
{{ input autofocus="true" }}
:
{{ autofocus }}
{# end of file #}
Setting the keyboard focus on a specific input
element is a quite standard UI behaviour but rather tedious to accomplish in Ember.
Gladly, there’s this very useful recipe on the Ember web site on how you’re supposed to do that; basically, you set the focus after the didInsertElement
Ember event fires - done! This, this and this Stackoverflow answer propose similar techniques.
Unfortunately, the proposed solutions require subclassing into your own View
s, which I do not like so much for various reasons.
Thus, Change!
ember-autofocus
bundles Ember's proposed technique into a neat package and adds a few improvements along the way:
autofocus
attribute if available.autofocus
attribute for InputField
for HTML5 compatibility{{autofocus}}
View
that uses jQuery to set the focusbower install ember-autofocus
In your index.html
:
<script type="text/javascript" src="bower_components/ember-autofocus/dist/ember-autofocus.min.js)"></script>
<input|button|textarea>
element with an autofocus
attribute.// myView.handlebars
:
{{ input autofocus="autofocus"}}
:
{{ autofocus }}
{# end of file #}
Autofocus on the first <input>
element.
// myView.handlebars
:
{{ input }}
:
{{ autofocus }}
{# end of file #}
Use a CSS selector to autofocus on a specific element.
// myView.handlebars
:
{{ autofocus on='#my-special-element .my-unique-class' }}
{# end of file #}
Safari, Chrome, Firefox and possibly other HTML5 browsers that support autofocus
natively will set the keyboard focus to the specified field and will automatically scroll there. In my use case, that's not wanted because the input field may be below the screen fold and automatically scrolling there is not what users would expect.
You can choose whether or not you want the scrolling behavior with the scrolling
option:
scrolling = "true|false"
The default is false
, which means that the browser will not scroll to the autofocus
element.
// myView.handlebars
:
{{ autofocus scrolling="true" }}
{# end of file #}
I have found some very valuable advice during my research which I have built into ember-autofocus
:
autofocus
feature detection snippet.Copyright (c) 2014 Andreas Pizsa. Released under an MIT license.
Made with ❤ in Vienna, Austria.
FAQs
Automatically focus on an input field upon page load in Ember
The npm package ember-autofocus receives a total of 1 weekly downloads. As such, ember-autofocus popularity was classified as not popular.
We found that ember-autofocus 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.