jQuery UI 1.6 The User Interface Library for jQuery phần 6

Lưu tập tin này như . Trong ví dụ này, chúng ta đều DO IS Cung cấp bổ sung đánh dấu-up, các chuỗi nguyên tố đen Trong nối với kết quả từ các nguồn dữ liệu cho tiêu đề và thuộc tính href. Không bao giờ tâm đó sẽ Nhấp vào liên kết | Auto-Complete Prototype Regular Expressions Strings Scope Typeof Undefined Variables XHR provide additional markup for each result function customItem data i max add the link return data 0 a href data 0 .html title data 0 data 0 a create config object var autocompOpts formatItem customItem turn specified element into an auto-complete suggest .autocomplete autocompOpts script body html Save this file as . In this example all we do is provide the additional mark-up the a element within a literal string concatenated with the result from the data source for the href and title attributes. Never mind that clicking on the link will cause the suggestion to be added to the text field instead of the link being followed as we could easily add an additional click handler for this event and move the browser to the new page manually. Or perhaps the links could be triggers for some kind of tooltip. The example is about adding additional formatting in the form of new mark-up and that is exactly what we ve done. The formatItem property is useful as it allows us to specify an alternative format for the results presented in the suggestion menu. The premise is similar to that of the highlight function although in the case of formatItem a regular expression is not needed to achieve the custom formatting. The function we specify as the value of formatItem receives four arguments when it is called. It receives the result the row or number of the result the total number of results and the search term that was typed into the input field. 200 Chapter 7 The result is the data the word returned as a result and the row corresponds to the number of the result. What is meant by this is that the first result will have a row number of 1 the second result will have a row number of 2 etc. The total and term values should not need further explanation. The additional formatting provided by this example is shown in the following screenshot I jjQuery UI Auto Complete Widget Examples -

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
18    78    2    07-05-2024
242    118    1    07-05-2024
283    575    1    07-05-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.