Practical prototype and scipt.aculo.us part 28

Practical prototype and part 28: 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 7 ADVANCED JAVASCRIPT FUNCTIONAL PROGRAMMING AND CLASS-BASED OOP 153 var Totaler initialize function element totalElement options element totalElement selector .number options updateTotal function var numberElements var total 0 function memo el return memo Number Finally we fill in totalElement with the sum using Element update. And we also modify initialize so that it calls updateTotal so that the sum is computed automatically when Totaler is instantiated. var Totaler initialize function element totalElement options element totalElement selector .number options updateTotal function var numberElements var total 0 function memo el return memo Number total We re done writing the Totaler class at least for now. Save it as . 154 CHAPTER 7 ADVANCED JAVASCRIPT FUNCTIONAL PROGRAMMING AND CLASS-BASED OOP Testing Now find the file you created for Chapter 6. Copy it over to your Chapter 7 folder. We ll be using the same data for this example but we ll need to change the table s markup to fit with the changes we ve made. Alter the table until it looks like this table id cities caption Major Texas Cities caption thead tr th scope col Name th th scope col class number Population Metro Area th th scope col Airport Code th tr thead tfoot tr th scope row Total th td class number id population_total td td td tr tfoot tbody tr id dallas th scope row Dallas th td class number 6003967 td td class code DAL td tr tr id houston th scope row Houston th td class number 5539949 td td class code IAH td tr tr id san_antonio th scope row San Antonio th td class number 1942217 td td class code SAT td tr CHAPTER 7 ADVANCED JAVASCRIPT .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
5    363    1    29-04-2024
347    72    2    29-04-2024
Đã 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.