Skip to content

Instantly share code, notes, and snippets.

@notbrain
Created June 30, 2011 16:29
Show Gist options
  • Save notbrain/1056595 to your computer and use it in GitHub Desktop.
Save notbrain/1056595 to your computer and use it in GitHub Desktop.
// prevent tabbing from moving the slides around
// intercept with preventDefault and tab back to field with initial focus class based on current slide #
$(".tabBackToInitialFocus").keydown(function(event){
if(event.keyCode == 9) { // tab key
event.preventDefault();
// currentSlideNumber is set after each navigation action (click on "Next"/"Back" buttons, etc)
$(".initialFocus" + currentSlideNumber).select();
}
});
<!-- ... -->
<dt>Slide 2</dt>
<dd>
<h2>Profile - Step 1 of 4</h2>
<div class="container section">
<div class="editCompanyFormWrap column1" style="">
<div class="formrow">
<label for="cname">Company Name </label>
<input type="text" name="cname" class="text initialFocus2" value="" />
</div>
<div class="formrow">
<label for="">Company URL</label>
<input type="text" name="cwebsite" class="text" value="" />
</div>
<div class="formrow">
<label for="">Careers URL</label>
<!-- Without intercept tabbing from here would throw the slide into mis-alignment,
showing the next slide partially -->
<input type="text" name="url_career_page" class="text tabBackToInitialFocus" value="" />
</div>
</div>
</div>
</dd>
<!-- ... -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment