|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Chowarmaan Smarty n00b
Joined: 16 Aug 2013 Posts: 1
|
Posted: Fri Aug 16, 2013 5:19 pm Post subject: Option to specify field for focus when form loaded |
|
|
I am looking at a number of pages that all have different controls and visibility that are being built using Smarty templates. The common problem I find is that input pages do not have the first field active with the cursor in it.
I could write an OnLoad onto every page, but thought it would be better to be able to specify this with a attribute of the field for Smarty to take care of.
Is it possible to use something like a Focus attribute on fields, and the first visible one encounter (or first one period) would have the .focus() applied to it when the page is loaded?
Is there an existing way to do this same thing without needing to write:
Code: | <body onload="document.forms.addKey.keyword.focus();"> |
on all pages? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Aug 16, 2013 8:01 pm Post subject: |
|
|
That would be managed in javascript, jQuery would be something like:
Code: | $(document).ready(function() {
$('form:first *:input[type!=hidden]:first').focus();
}); |
Smarty won't be aware of javascript or forms on the page, it is just text to the template engine. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|