tailieunhanh - ASP.NET AJAX Programmer’s Reference - Chapter 16

Behaviors Hành vi là một phần của chức năng có thể được gắn vào một phần tử DOM. Vì vậy một hành vi là một phương tiện mở rộng các chức năng của phần tử DOM mà hành vi này là. Không phải tất cả các hành vi có thể được gắn liền với mọi phần tử DOM. Chương này sẽ cung cấp cho bạn chuyên sâu trong phạm vi bảo hiểm của một số hành vi tiêu chuẩn của AJAX giúp bạn có được những kỹ năng cần thiết để phát triển các hành vi tùy chỉnh của. | Behaviors A behavior is a piece of functionality that can be attached to a DOM element. Therefore a behavior is a means of extending the functionality of the DOM element to which the behavior is attached. Not every behavior can be attached to every DOM element. This chapter will provide you with in-depth coverage of some of the standard AJAX behaviors and help you gain the skills you need to develop your own custom behaviors. What is a Behavior Anyway I ll begin our discussions with the simple page shown in Listing 16-1. As you can see this page contains a span HTML element that displays the text Wrox Web Site. Moving the mouse over this link toggles the CSS class of this span element. As the boldface portion of Listing 16-1 shows the pageLoad method first invokes the get global JavaScript function to return a reference to the span HTML element var labell get label1 Next it invokes the addHandler global JavaScript function to register a JavaScript function named toggleCssClass as an event handler for the mouseover event of the span HTML element addHandler label1 mouseover toggleCssClass Finally it invokes the addHandler JavaScript function once more to register the toggleCssClass function as an event handler for the mouseout event of the span HTML element addHandler label1 mouseout toggleCssClass As you can see from the boldface portion of Listing 16-1 the toggleCssClass function simply invokes the toggleCssClass static method on the DomElement class passing in the event target Chapter 16 Behaviors which simply references the span HTML element and the string that contains the CSS class of interest function toggleCssClass domEvent CssClass1 Now imagine a situation in which you need to do the same thing with many other span and label HTML elements in your application. You can t reuse the code shown in the boldface portion of Listing 16-1 because it is tied to the specific span element on this specific page in .

crossorigin="anonymous">
Đã 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.