tailieunhanh - Practical prototype and scipt.aculo.us part 44

Practical prototype and part 44: The information in this book is distributed on an "as is" basis, without warranty Although every pre-caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. | CHAPTER 10 INTRODUCTION TO EFFECTS 253 update the score cell with the player s point total from the JSON .update dom loaded function var teamltotaler new Totaler team_1 team_1_total selector tbody .score var team2totaler new Totaler team_2 team_2_total selector tbody .score score updated function the memo property holds the custom data we attached to the event var json break the JSON in half -- one piece for each table. updateTeam table_1 updateTeam table_2 script In other words recomputing the total needs to be the last thing we do when a score updates. Now we need to emphasize rows when they change. This is the perfect use case for the effect that pulses an element s background color to draw attention to it. For this we ll need to add some logic to our updateTeam function script type text javascript charset utf-8 function updateTeam table json table table a team is divided into several positions var positionStats row for var position in json positionStats json position 254 CHAPTER 10 INTRODUCTION TO EFFECTS match up the JSON property name WR1 RB2 TE etc. with the table row that has the corresponding class name row tr. position var scoreCell oldValue Number update the score cell with the player s point total from the JSON is the new value larger than the old value if oldValue new row dom loaded function var teamltotaler new Totaler team_1 team_1_total selector tbody .score var team2totaler new Totaler team_2 team_2_total selector tbody .score score updated function the memo property holds the custom data we attached to the event var json break the JSON in half -- one piece for each table. updateTeam

TỪ KHÓA LIÊN QUAN