<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Input focus with jQuery</title>
	<atom:link href="http://greatwebguy.com/programming/dom/input-focus-with-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/</link>
	<description>Self-proclaimed greatness is a hard thing to prove.</description>
	<lastBuildDate>Mon, 01 Mar 2010 19:05:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mike Nicewarner</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-1276</link>
		<dc:creator>Mike Nicewarner</dc:creator>
		<pubDate>Mon, 01 Mar 2010 19:05:10 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-1276</guid>
		<description>Hey guys.

I&#039;m trying to make a site that uses PHP in the backend, jQuery to make the UI fancy, and Ajax calls to populate some of the elements.  I have a page that shows a bunch of data from a table, using Ajax to get back just a few records at a time.  I have a filtering system where I use INPUT fields to let the user filter the data.  My problem is that the INPUT field itself is being created by the same Ajax call.  What happens is that the INPUT field loses focus no matter what I do.
So far, if I combine .select() and .focus(), I can get the focus to the *beginning* of the text field, which doesn&#039;t really work for a &quot;type into&quot; application.  If I want to filter by &quot;Jones&quot;, I end up with &quot;senoJ&quot;.
My code is:
var savedfiltfield;
...
$(&#039;tr.filter input&#039;).live(&#039;keyup&#039;, function() {
	savedfiltfield = $(this).attr(&#039;id&#039;);
	setfilt($(this));
});
...
// in setfilt() function:
$.get(&#039;listing_ajax.php&#039;, {type : type, page : newpage, sort : sort, filt : filt, rowcnt : rowcnt},
	function(data) {
		$(&#039;table#maindata&#039;).html(data);
		$(&#039;input.#&#039;+savedfiltfield).focus();
	}
);

If I add .select() after the .focus(), it will select the text.  If I put .select() before the .focus(), it will put the cursor at the beginning of the field.

HELP!?!?

Thanks.</description>
		<content:encoded><![CDATA[<p>Hey guys.</p>
<p>I&#8217;m trying to make a site that uses PHP in the backend, jQuery to make the UI fancy, and Ajax calls to populate some of the elements.  I have a page that shows a bunch of data from a table, using Ajax to get back just a few records at a time.  I have a filtering system where I use INPUT fields to let the user filter the data.  My problem is that the INPUT field itself is being created by the same Ajax call.  What happens is that the INPUT field loses focus no matter what I do.<br />
So far, if I combine .select() and .focus(), I can get the focus to the *beginning* of the text field, which doesn&#8217;t really work for a &#8220;type into&#8221; application.  If I want to filter by &#8220;Jones&#8221;, I end up with &#8220;senoJ&#8221;.<br />
My code is:<br />
var savedfiltfield;<br />
&#8230;<br />
$(&#8216;tr.filter input&#8217;).live(&#8216;keyup&#8217;, function() {<br />
	savedfiltfield = $(this).attr(&#8216;id&#8217;);<br />
	setfilt($(this));<br />
});<br />
&#8230;<br />
// in setfilt() function:<br />
$.get(&#8216;listing_ajax.php&#8217;, {type : type, page : newpage, sort : sort, filt : filt, rowcnt : rowcnt},<br />
	function(data) {<br />
		$(&#8216;table#maindata&#8217;).html(data);<br />
		$(&#8216;input.#&#8217;+savedfiltfield).focus();<br />
	}<br />
);</p>
<p>If I add .select() after the .focus(), it will select the text.  If I put .select() before the .focus(), it will put the cursor at the beginning of the field.</p>
<p>HELP!?!?</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Red</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-1217</link>
		<dc:creator>Joe Red</dc:creator>
		<pubDate>Wed, 03 Feb 2010 22:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-1217</guid>
		<description>Thank you a lot. I will go ahead and purchase the book I mean, I have been going off and on to the API documentation and  I have managed to add few jquery features to some sites I have worked on however I feel like I gotta work more on the fundamentals and concepts. Every time I have to use JQuery I end up fishing some pieces of code written by somebody else (which is not bad per sea) but it doesn&#039;t come easy.

Cheers.</description>
		<content:encoded><![CDATA[<p>Thank you a lot. I will go ahead and purchase the book I mean, I have been going off and on to the API documentation and  I have managed to add few jquery features to some sites I have worked on however I feel like I gotta work more on the fundamentals and concepts. Every time I have to use JQuery I end up fishing some pieces of code written by somebody else (which is not bad per sea) but it doesn&#8217;t come easy.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webguy</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-1216</link>
		<dc:creator>webguy</dc:creator>
		<pubDate>Wed, 03 Feb 2010 14:48:28 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-1216</guid>
		<description>jQuery has great documentation for their API at &lt;a href=&quot;http://docs.jquery.com/Main_Page&quot; rel=&quot;nofollow&quot;&gt;http://docs.jquery.com/Main_Page&lt;/a&gt;, of course there are tutorials and examples throughout the Internet.  When I first started out I skimmed a book called Learning jQuery by Jonathan Chaffer and Karl Swedberg, once you get a lot of the concepts down you&#039;ll find that you&#039;ll use the API documentation 90% of the time.</description>
		<content:encoded><![CDATA[<p>jQuery has great documentation for their API at <a href="http://docs.jquery.com/Main_Page" rel="nofollow">http://docs.jquery.com/Main_Page</a>, of course there are tutorials and examples throughout the Internet.  When I first started out I skimmed a book called Learning jQuery by Jonathan Chaffer and Karl Swedberg, once you get a lot of the concepts down you&#8217;ll find that you&#8217;ll use the API documentation 90% of the time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Red</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-1215</link>
		<dc:creator>Joe Red</dc:creator>
		<pubDate>Wed, 03 Feb 2010 05:23:09 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-1215</guid>
		<description>Hi there. Guys, I have been using JQuery for the last 8 months and the more I use it the more I like it. The question I have is: Is there a bible for JQuery written down or Online which I can consult and study to become a Guru in the subject? can you direct it to me? 

I really appreciate it.</description>
		<content:encoded><![CDATA[<p>Hi there. Guys, I have been using JQuery for the last 8 months and the more I use it the more I like it. The question I have is: Is there a bible for JQuery written down or Online which I can consult and study to become a Guru in the subject? can you direct it to me? </p>
<p>I really appreciate it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webguy</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-1187</link>
		<dc:creator>webguy</dc:creator>
		<pubDate>Tue, 05 Jan 2010 13:08:22 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-1187</guid>
		<description>Actually there was a need to complicate it a little in order to have a level of control, with shared templates there&#039;s a need for a hierarchy of focus, this is why I chose to give a class to the objects in the page that typically have focus and then apply focus to the last element with that class based on the document order.</description>
		<content:encoded><![CDATA[<p>Actually there was a need to complicate it a little in order to have a level of control, with shared templates there&#8217;s a need for a hierarchy of focus, this is why I chose to give a class to the objects in the page that typically have focus and then apply focus to the last element with that class based on the document order.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vlado Cingel</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-1186</link>
		<dc:creator>Vlado Cingel</dc:creator>
		<pubDate>Tue, 05 Jan 2010 10:35:47 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-1186</guid>
		<description>There is no need to complicate things. You can do everything using selectors, following code will set focus on first visible input.

&lt;code&gt;$(&quot;input:text:visible:first&quot;).focus();&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>There is no need to complicate things. You can do everything using selectors, following code will set focus on first visible input.</p>
<p><code>$("input:text:visible:first").focus();</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xiara</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-1098</link>
		<dc:creator>Xiara</dc:creator>
		<pubDate>Mon, 29 Jun 2009 18:38:39 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-1098</guid>
		<description>Thanks, I needed this for one of the sites I&#039;m working on...</description>
		<content:encoded><![CDATA[<p>Thanks, I needed this for one of the sites I&#8217;m working on&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webguy</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-630</link>
		<dc:creator>webguy</dc:creator>
		<pubDate>Tue, 24 Jun 2008 01:46:05 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-630</guid>
		<description>Paul, thanks for the advice, I&#039;ve updated the post again to reflect it.  I&#039;ve truly been schooled on this one.</description>
		<content:encoded><![CDATA[<p>Paul, thanks for the advice, I&#8217;ve updated the post again to reflect it.  I&#8217;ve truly been schooled on this one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: paul irish</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-629</link>
		<dc:creator>paul irish</dc:creator>
		<pubDate>Mon, 23 Jun 2008 21:15:10 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-629</guid>
		<description>using a class selector without a tagname is far far far slower. always use &quot;input.focus&quot; instead of &quot;.focus&quot; when possible.</description>
		<content:encoded><![CDATA[<p>using a class selector without a tagname is far far far slower. always use &#8220;input.focus&#8221; instead of &#8220;.focus&#8221; when possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webguy</title>
		<link>http://greatwebguy.com/programming/dom/input-focus-with-jquery/comment-page-1/#comment-628</link>
		<dc:creator>webguy</dc:creator>
		<pubDate>Sat, 21 Jun 2008 22:15:42 +0000</pubDate>
		<guid isPermaLink="false">http://greatwebguy.com/?p=49#comment-628</guid>
		<description>I stand corrected, I misinterpreted the doc, I&#039;ll update the post.  Thanks for the feedback.</description>
		<content:encoded><![CDATA[<p>I stand corrected, I misinterpreted the doc, I&#8217;ll update the post.  Thanks for the feedback.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
