Nav & Search

Using JavaScript to Select Part of an Input

Coding - November 29th, 2011

I recently had to develop a suggestion feature for an input-field where the first best match would be filled in and the rest of the word selected so that the user can continue writing if that’s not the correct word. At first this seemed like a straight-forward solution but then I realized that to select text programmatically in the document isn’t exactly straight forward (neither is searching inside an array, but that’s another story).

The reason that it isn’t straight-forward is that like som many other features of web technology it’s implemented in different same ways in Internet Explorer as it is in the rest of the major (and W3C compliant) browsers.

(more…)

Touch and Drag on the iPad Using jQuery

Coding - November 3rd, 2011

One of the fundamental features of a mobile web app is the ability is use gestures to touch and drag items or layout sections. This is one way to do it using jQuery to listen and react to the touch events and CSS transforms to implement the actual moves of the objects. There might be situations where normal CSS positioning is better (when other elements should react, for example) but using 3D CSS transforms makes it possible to use hardware acceleration for the items which will make the movements much smoother than otherwise possible and get a nice native feel.

(more…)