Rails2.3 Ajax paging Implementation Scheme

Source: Internet
Author: User

I haven't posted a post for a while, so I experienced a very stressful June (examination + project tightening), and I will continue to improve the project during the summer vacation. So I have never thought about anything.

To be honest, it is really boring to improve functions. I don't want to get it because of it. Maybe it's because I 've been doing it for a long time. If you are tired, you are willing to visit the website and read technical posts,
When I listen to songs, I can't talk about fatigue. After all, I have no learning concerns during the holidays. I am tired of reading it, because the architecture of this system makes me more and more complicated. I should be careful when adjusting each step, for fear of affecting it.
Other modules. I want to charge myself more and learn the technologies I are interested in. It is because I clearly know my technical shortcomings.

Today, I saw a senior graduate who posted a translation technical article about PHP optimization. I admire it very much because his pursuit of technology is always so hot, he wrote the latest articles in tuboi.
I felt more or less that I should write something, but I was still a little hesitant. Later I saw his blog post in his garden space and only talked about his technical blog, start to write this article. Maybe it is
I don't like to post articles in tuboi. In short, this allows me to see a lot of people who inspire me. My QQ Technology Group also has more than 180 people who love technologies and are willing to communicate with me.
Thanks to them, they also feel that they are not interesting enough. They always dive and do not really communicate with each other. With this in mind, I feel that I should cheer up myself, even if I know that the road will be bitter in the future, I should stick to it. Because
I have made a choice in my life.

Rails I am using the latest version 2.3. rails has been quickly promoted by web Developers since its rapid and agile development. However, I may be used to the Java Development Mode and think that rails
I feel like building blocks and making puzzles. The speed is indeed faster, and it is much faster than j2ee, but it makes me feel that this architecture is not under my control and it is encapsulated too closely, and the methods are encapsulated for you, let me use it directly,
I guess I just got started and didn't know him well.

Example: Ajax Paging
1. First, expand the will_paginate plug-in. Because the plug-in is not supported by default, find the view_helpers.rb source file in the plug-in.
Add code: Def will_paginate_remote (paginator, options = {})
Update = options. delete (: update)
Url = options. delete (: url)
Str = will_paginate (paginator, options)
If str! = Nil
Str. gsub (/href = "(.*?) "/) Do
"Href = \" # \ "onclick = \" new Ajax. Updater ('"+ update +"', '"+ (url? Url + $ 1.sub(/[^ \?] */, ''): $1) +
"', {Asynchronous: true, evalScripts: true, method: 'get'}); return false ;\""
End
End
End

2. Add: <% = Javascript_include_tag: defaults %>

3. Modify the paging Method on this page: <% = Will_paginate_remote (@ blogs,: update => 'blogs',: url => nil,: prev_label => 'previous page',: next_label => 'Next page ',: separator => "|") %>

OK, it's all done, so an Ajax page is done, isn't it very fast. This is also the charm. Use jquery + java to implement
This function will certainly take a lot of time. However, this is the end of the process, and it is truly unbearable. It is better than dragging. net controls.

Ah, I found myself getting lazy. I posted a post to spur myself. Come on!
I will continue to improve my project. After activation, I will write an article on the architecture design, exchange, and progress of this project.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.