-
Notifications
You must be signed in to change notification settings - Fork 13
Using jquery_ujs
The rationale behind using jquery_ujs is that AJAX Pagination is not just easy to use. It should also include the features that users of the gem will want to use. If a developer wants to ajaxify the whole website, it is natural that all links should load content using AJAX.
But why stop at simple links? For example, the "Destroy" link in rails scaffolds, is actually a DELETE request. There may also exist forms to post content, or edit content. These may be POST or PUT requests. In order to support these requests, additional logic is required. However, the jquery_ujs gem already handles this logic. Therefore, it is natural for AJAX Pagination to depend on jquery_ujs to support this functionality.
That is why all links and forms using AJAX Pagination also uses jquery_ujs to make the AJAX request, and retrieve the response.
It is worth mentioning that AJAX Pagination does not use jquery_ujs to make AJAX requests when browser history is used. This is because no link or form is explicitly activated (which jquery_ujs requires), and in any case, only GET requests need to be supported when using browser history. Always using GET requests when accessing content through browser history is an important design feature. This is because only GET requests are guaranteed to be safe. No browser should perform unsafe operations without explicit user action. This means AJAX Pagination should not allow unsafe requests through browser history.