[FIX] clear search button work anywhere on website page
This commit is contained in:
parent
284c4d305f
commit
1d1b0a789f
@ -1,3 +1,33 @@
|
||||
flectra.define('website_sale.clear_search', function (require) {
|
||||
"use strict";
|
||||
|
||||
require('web.dom_ready');
|
||||
|
||||
var $search_box = $('.oe_search_box');
|
||||
var _clear_search_btn = function (e){
|
||||
var $search_clear_btn = $('.oe_search_clear_button');
|
||||
if($(e).val().trim()){
|
||||
$search_clear_btn.removeClass('hidden');
|
||||
}else{
|
||||
$search_clear_btn.addClass('hidden');
|
||||
}
|
||||
};
|
||||
|
||||
_clear_search_btn($search_box);
|
||||
|
||||
$search_box.on('keyup', function (event) {
|
||||
_clear_search_btn(this);
|
||||
});
|
||||
$('.oe_search_clear_button').on('click', function (e) {
|
||||
var $form = $(this).parents('form');
|
||||
$form.find('.oe_search_box').val('');
|
||||
if(window.location.pathname != '/'){
|
||||
$form.trigger('submit');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
flectra.define('website_sale.cart', function (require) {
|
||||
"use strict";
|
||||
|
||||
@ -438,26 +468,6 @@ flectra.define('website_sale.website_sale', function (require) {
|
||||
window.location = oldurl + '&' + search.attr('name') + '=' + encodeURIComponent(search.val());
|
||||
}
|
||||
});
|
||||
|
||||
var $search_box = $('.oe_website_sale .oe_search_box');
|
||||
var _clear_search_btn = function (e){
|
||||
var $search_clear_btn = $('.oe_website_sale .oe_search_clear_button');
|
||||
if($(e).val().trim()){
|
||||
$search_clear_btn.removeClass('hidden');
|
||||
}else{
|
||||
$search_clear_btn.addClass('hidden');
|
||||
}
|
||||
};
|
||||
|
||||
_clear_search_btn($search_box);
|
||||
|
||||
$search_box.on('keyup', function (event) {
|
||||
_clear_search_btn(this);
|
||||
});
|
||||
$('.oe_website_sale .oe_search_clear_button').on('click', function (e) {
|
||||
$('.oe_website_sale .oe_search_box').val('');
|
||||
$('.oe_website_sale .o_website_sale_search').trigger('submit');
|
||||
});
|
||||
}
|
||||
|
||||
if ($(".checkout_autoformat").length) {
|
||||
|
Loading…
Reference in New Issue
Block a user