Ajax|rails
Vii. use of observers
Rails allows you to monitor the value of a field and make an Ajax call to an action processor whenever a field value changes. The value of the currently observed field is sent to the action handler for the sending data associated with this call.
One of the most common scenarios is to implement a live lookup:
live Search: <%= Text_field_tag:searchtext%> <%= Observe_field (: SearchText, : Frequency => 0.25, : Update =>: Search_hits, : URL => {: Action =>: Live_search})%>
Search Results:
|
This small snippet implementation monitors the value of a text box field called SearchText. Every One-fourth seconds, rails checks the field for changes. If the field changes, the browser makes an Ajax call to the Live_search action processor and displays the results in the search_hits Div.
You can see an actual display of this kind of onsite lookup on my blog. In the search box in the upper-right corner, you can try typing "enterprise" or "rails" to see what's going on.
VIII. Application of Ajax technology
When you use AJAX technology to update a part of a Web page, the user gets a quick response and fluency. However, users also lose the ability to bookmark functionality and use the browser's Back button. The two drawbacks come from the same fact: URLs do not change because browsers do not load a new page.
Don't use it just because it's pretty cool, but consider what's most important in your Web application's user interface.
For example, if a Web page displays an account list-there are operations such as adding, deleting, and renaming accounts, and so on, these are good candidates for Ajax. If the user clicks on a hyperlink to display all the listings belonging to an account-in this case, you should display a new page and avoid Ajax.
This means that the user can write down the Account page and the list page and switch between them using the backward and forward buttons. Users cannot note the actions in one of these lists or use the Back button to try to undo an action on the list (in a traditional Web application, both of which you want to avoid).
Tim Head
I'd like to introduce you to a lot of really cool things, but it's not going to go into the details to discuss.
Web page upload file function often make some users frown, because the user in the upload process, he will not receive any feedback, in addition to the screen of the funnel mouse is constantly turning around ... By using AJAX technology, you can communicate with the server-during the upload process, you can retrieve and display the status of the upload. Sean Treadway and Thomas Fuchs implemented a live display of how to implement this technique by using rails and a video.
In addition, rails uses a prototype JavaScript library that also achieves a large amount of visualization. The Effect demo page has an online demo of these effects, including JavaScript calls to use.
10, feelings
The web has experienced a considerable amount of mileage since an isolated web site served a static page. Now, we are slowly moving into a new era-sites are dynamically linked together, the Web API allows us to easily create this on existing services, and the Web user interface has become more fluid and responsive. It is clear that Ajax will play a pivotal role in today's 2.0 legendary web-surfaced legends.
In any case, adding complex AJAX features to a Web application should be a lot of work, but rails makes it all too easy.