A
A
Alexander Ivanov2018-02-13 12:51:03
JavaScript
Alexander Ivanov, 2018-02-13 12:51:03

How to correctly generate a URL using jQuery?

The page has pagination, it works correctly without filters.
If filters are applied, a huge URL is formed and pagination stops working.

function toggleDom(dom) {
    //если включен - выключим
    if ($("#for_number" + dom).hasClass('active')){
        $("#for_number" + dom).removeClass('active');
        $("#Kvartiry_doma_" + dom).val(0);
    }
    else{
        $("#for_number" + dom).addClass('active');	
        $("#Kvartiry_doma_" + dom).val(1);
    }
}


One of the filter buttons on the form:
<a  id="for_number1a" 
 class="dom_number<?= $model->doma['1a'] ? ' active' : '' ?>" 
onclick="toggleDom('1a'); return false;">1А
</a>


received
URL http://mysite/kvartiry?Kvartiry_page=3&Kvartiry_p...

How to fix the JS code so as not to damage the pagination when using the filter and at the same time fix the url?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-02-13
@Maksclub

Convenient JQuery lib for working with Query Params:
https://github.com/alrusdi/jquery-plugin-query-object

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question