Đang chuẩn bị liên kết để tải về tài liệu:
Practical prototype and scipt.aculo.us part 44

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Practical prototype and scipt.aculo.us 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 SCRIPT.ACULO.US EFFECTS 253 update the score cell with the player s point total from the JSON row.down td.score .update positionStats.points document.observe 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 document.observe score updated function the memo property holds the custom data we attached to the event var json event.memo break the JSON in half -- one piece for each table. updateTeam table_1 json.team_1 updateTeam table_2 json.team_2 team1totaler.updateTotal team2totaler.updateTotal 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 Effect.Highlight 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 SCRIPT.ACULO.US EFFECTS match up the JSON property name WR1 RB2 TE etc. with the table row that has the corresponding class name row table.down tr. position var scoreCell row.downCtd.score oldValue Number scoreCell.innerHTML update the score cell with the player s point total from the JSON scoreCell.update positionStats.points is the new value larger than the old value if position.points oldValue new Effect.Highlight row document.observe 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 document.observe score updated function the memo property holds the custom data we attached to the event var json event.memo break the JSON in half -- one piece for each table. updateTeam

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.