How to set autofocus only in xaml?
<TextBox FocusManager.FocusedElement=”{Binding RelativeSource={RelativeSource Self}}” />
<TextBox FocusManager.FocusedElement=”{Binding RelativeSource={RelativeSource Self}}” />
What I did was I created an extra input and made it invisible (style=”display:none”) then gave it the property autofocus=”true” put this at the end of your dialog content so it wont mess with anything. it should look like this: <div><!–dialog div–> <button></button> <button></button> <input type=”hidden” autofocus=”true” /> </div>
You don’t need to import the ‘Input’ from ‘angular/core’. Simply: import {Component,ViewChild} from ‘@angular/core’; import {NavController, TextInput } from ‘ionic-angular’; @Component({ templateUrl: ‘build/pages/home/home.html’ }) export class HomePage { @ViewChild(‘input’) myInput: TextInput; constructor(private navCtrl: NavController) { } ionViewDidLoad() { setTimeout(() => { this.myInput.setFocus(); },150); } } And answering comment to Ciprian Mocanu: It does not work … Read more
It looks like you’re definitely hitting an iOS 8 bug. In iOS7, Safari would (apparently) ignore or keep unfocused elements that had focus set prior to page load. This includes both <input autofocus> and input.focus() that occur up to some point, possibly page load (I tested just with an inline script). In iOS 8, Safari … Read more
I think this is a feature of mobile Safari rather than a bug. In our work on FastClick, my colleagues and I found that iOS will only allow focus to be triggered on other elements, from within a function, if the first function in the call stack was triggered by a non-programmatic event. In your … Read more
Add the android:focusable=”true” and android:focusableInTouchMode=”true” elements in the parent layout of EditText as follow; <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/linearLayout7″ android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:focusable=”true” android:focusableInTouchMode=”true”> I think, it should help you. See also; Android Developers official guide on handling touch and input
In HTML, you use boolean attributes with or without values as you like. A boolean, for W3C, like autofocus can be written like that autofocus or autofocus=”autofocus” or also autofocus=””. If you don’t want autofocus just don’t write it. I think you are confused because XHTML requires values for all attributes: attributes=”values”. Here is some … Read more
And you can use HTML5’s autofocus attribute (works in all current browsers except IE9 and below). Only call your script if it’s IE9 or earlier, or an older version of other browsers. <input type=”text” name=”fname” autofocus>