I need to update search (query) parameters in URL if user enters those in search panel (on a page). I'm trying this:
$( document ).ready(function() {
if ($('.o_website_license_search_panel').length) {
$('.o_website_license_search_panel .o_search_submit').click(function () {
var search = $.deparam(window.location.search.substring(1));
console.log('before update')
console.log(window.location.search)
search.license_key = $(".o_website_license_search_panel input[name='license_key']").val();
console.log('new obj ', search, $.param(search))
window.location.search = $.param(search);
console.log('after update')
console.log(window.location.search)
});
}
});
And I get this output:
before update
web.assets_frontend.js:1254 ?license_state=cancel
web.assets_frontend.js:1255 new obj {license_state: "cancel", license_key: "test2"} license_state=cancel&license_key=test2
web.assets_frontend.js:1256 after update
web.assets_frontend.js:1257 ?license_state=cancel
As you can see window.location.search
stays the same. Is there something I miss, or it is intended this way?..
form
with methodpost
(for that same inputlicense_key
), which would trigger page reload too. So it looks like that one have taken priority and it would override JS part and I would not seewindow.location.search
being updated. Once I disabled that form,window.location.search
started being updated properly. – Glamorize