is there a way to put the focus on a particular field when a form is presented to the user using a LiftScreen ? I didn't find an answer in this list when searching for "FocusOnLoad" or "LiftScreen".
I didn't try it myself, but I guess you could add an attribute to your form field, e.g. a specific class name (like 'focus') or you could set the tabindex to 1 on that field. Then you should be able to identify that field via JavaScript and set the focus.
On Thursday, March 1, 2012 9:38:05 PM UTC+1, Scaalp wrote:
> Hello,
> is there a way to put the focus on a particular field when a form is > presented to the user using a LiftScreen ? > I didn't find an answer in this list when searching for "FocusOnLoad" or > "LiftScreen".
On Fri, Mar 2, 2012 at 2:30 PM, Sören Kress <soeren.kr...@gmail.com> wrote: > I didn't try it myself, but I guess you could add an attribute to your > form field, e.g. a specific class name (like 'focus') or you could set the > tabindex to 1 on that field. Then you should be able to identify that field > via JavaScript and set the focus.
> Best regards > Soeren
> On Thursday, March 1, 2012 9:38:05 PM UTC+1, Scaalp wrote:
>> Hello,
>> is there a way to put the focus on a particular field when a form is >> presented to the user using a LiftScreen ? >> I didn't find an answer in this list when searching for "FocusOnLoad" or >> "LiftScreen".
> That would add a script to the page to do whatever you wanted.
> On Fri, Mar 2, 2012 at 2:30 PM, Sören Kress wrote:
>> I didn't try it myself, but I guess you could add an attribute to your >> form field, e.g. a specific class name (like 'focus') or you could set the >> tabindex to 1 on that field. Then you should be able to identify that field >> via JavaScript and set the focus.
>> Best regards
>> Soeren
>> On Thursday, March 1, 2012 9:38:05 PM UTC+1, Scaalp wrote:
>>> Hello,
>>> is there a way to put the focus on a particular field when a form is >>> presented to the user using a LiftScreen ?
>>> I didn't find an answer in this list when searching for "FocusOnLoad" or >>> "LiftScreen".
following the path given by David, I reached my goal with the following code : override def screenTop = recipient.uniqueFieldId.map(id => <span>{Script(OnLoad(Focus(id)))}</span>)
But this seems a bit awkard to me, as I had to add a span, to transform the Node returned by Script into the Elem needed by screenTop. Maybe should screenTop be of type Box[Node], instead of Box[Elem] ?
But I found another way that pleases me better : overwrite the toForm method of my LiftScreen : override def toForm = recipient.uniqueFieldId.map(id => Script(OnLoad(Focus(id)))).toOption ++: super.toForm