How to customize the ajax pagination for back history?

77
February 14, 2021, at 11:30 AM

I am using pagination with ajax.

When i click on any page number url not changing because of ajax call

So when i click on page 3 and then click on page 7

i hit the back button it returns to page 1 because url never changing

Here is my code:

property_paging: function() {
        var handle = true;
        $('.paging-navigation', '.property-paging-wrap').each(function () {
            $('a', $(this)).off('click').on('click', function (event) {
                event.preventDefault();
                if(handle) {
                    handle = false;
                    var $this = $(this);
                    var href = $this.attr('href'),
                        data_paged = ERE.get_page_number_from_href(href),
                        data_contain = $this.closest('.property-paging-wrap'),
                        property_content = $this.closest('.ere-property').find('.property-content');
                    $.ajax({
                        url: data_contain.data('admin-url'),
                        data: {
                            action: 'ere_property_paging_ajax',
                            layout: data_contain.data('layout'),
                            items_amount: data_contain.data('items-amount'),
                            columns: data_contain.data('columns'),
                            image_size: data_contain.data('image-size'),
                            columns_gap: data_contain.data('columns-gap'),
                            view_all_link: data_contain.data('view-all-link'),
                            paged: data_paged,
                            property_type: data_contain.data('property-type'),
                            property_status: data_contain.data('property-status'),
                            property_feature: data_contain.data('property-feature'),
                            property_city: data_contain.data('property-city'),
                            property_state: data_contain.data('property-state'),
                            property_neighborhood: data_contain.data('property-neighborhood'),
                            property_label: data_contain.data('property-label'),
                            property_featured: data_contain.data('property-featured'),
                            author_id: data_contain.data('author-id'),
                            agent_id: data_contain.data('agent-id')
                        },
                        success: function (html) {
                            var $newElems = $('.property-item', html),
                                paging = $('.property-paging-wrap', html);
                            property_content.css('opacity', 0);
                            property_content.html($newElems);
                            ERE.set_item_effect($newElems, 'hide');
                            var contentTop = property_content.offset().top - 30;
                            $('html,body').animate({scrollTop: +contentTop + 'px'}, 500);
                            property_content.css('opacity', 1);
                            property_content.imagesLoaded(function () {
                                $newElems = $('.property-item', property_content);
                                ERE.set_item_effect($newElems, 'show');
                                property_content.closest('.ere-property').find('.property-paging-wrap').html(paging.html());
                                ERE.property_paging();
                                ERE.property_paging_control();
                                ERE.favorite();
                                ERE.tooltip();
                                ERE_Compare.register_event_compare();
                            });
                            handle = true;
                        },
                        error: function () {
                            handle = true;
                        }
                    });
                }
            })
        });
    },

the subject is a bit important. and my time is short. is there anyone who can help??

READ ALSO
Dynamically loading property value from active list of profiles and set the value in configuration XML file

Dynamically loading property value from active list of profiles and set the value in configuration XML file

I have a spring bath application which contains a batch configurationI want to dynamically load profile based upon the environemnt variable parameter of active profile list

81
WorkManager using setForegroundAsync() with ListenableWorker

WorkManager using setForegroundAsync() with ListenableWorker

A very useful guide and code snippet is provided for using setForegroundAsync() for a long-running worker in the context of a Worker in WorkManager

84
Update XML with an SQL query

Update XML with an SQL query

Let's say we have the following XML file:

81
TypeError: bdcls.map is not a function

TypeError: bdcls.map is not a function

I am finding it hard to consume data from the API i hosted on heroku using Axios

70