TAILIEUCHUNG - cakephp application development phần 10

Cũng giống như các liên kết () chức năng của helper AJAX, chức năng tự động hoàn chỉnh () cũng có ba tham số. Đầu tiên là tên của lĩnh vực này mà chúng ta đang quan tâm để AutoComplete. Điều này cần phải có một định dạng như thế này: . | Simpo PDF Merge and Split Unregistered Version - http Chapter 11 In step 7 we call the autoComplete function of the AJAX helper in the view of the search page by adding the following code to it php echo ajax- autoComplete array controller users action show_usernames array class fullwidth Just like the link function of the AJAX helper the autoComplete function also takes three parameters. The first is the name of the field that we are interested to AutoComplete. This should have a format like this . In the above code we used User. username as we want it to AutoComplete the user name. The next parameter is used to point the controller function to which the AJAX request will be sent to. Above we specified array controller users action show_usernames . We will be creating this action in the next step. The third parameter is used to send extra options to the function. For example here we specified that the class of the input text created should have a class fullwidth . In step 8 we added the action show_usernames to the Users controller. In the action we first defined the layout to be ajax so that only the content of the view is returned. We changed the Debug level to 0 so that no debug messages are returned. The AutoComplete code in the previous step also sends the user name or the partial user name entered by the user. This can be accessed in this- data User us ername . Lastly we send any user name that is like the entered text and who has confirmed their email address to the view of the action. In step 9 we create the view of the action. We put the matching user names into an unordered list and send it back to the browser. Lastly we add styles for the unordered list that will appear below the user name input. AJAX Form Submit to View Questions of a User In the previous section we used AJAX AutoComplete to pull all the matching usernames from the database and show them in a list. When the user selects one of the names

TỪ KHÓA LIÊN QUAN
Đã 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.