- Create a new Rails project named HighlightFocused.
- Generate a scaffold with the name Student having these fields:
Field | Datatype |
first_name | string |
middle_initial | string |
last_name | string |
gender | string |
birth_date | date |
gpa | float |
- Source code for the CSS stylesheet
HighlightFocused/app/assets/stylesheets/students.scss:
div.curFocus { background-color: #fdecb2;
width: 250px; }
div.field { padding: 10px; }
- Source code for the javascript source code: HighlightFocused/app/assets/javascripts/application.js:
$(document).ready(function( ) {
$("input").focus(function( ) {
$(this).parent( ).addClass("curFocus")
});
$("input").blur(function( ) {
$(this).parent( ).removeClass("curFocus")
});
});
- Localhost URL to view the Student index page:
http://localhost:3000/students
- If you prefer, remove the jQuery code in Step 4 and put this CoffeeScript
code in HighlightFocused/app/assets/javascripts/students.coffee:
$(document).ready ->
$("input").focus ->
$(this).parent( ).addClass("curFocus")
$("input").blur ->
$(this).parent( ).removeClass("curFocus")