Skip to Content
Odoo मेन्यू
  • साइन इन करें
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • आर्टिफ़िशियल इंटेलिजेंस
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    फ़ूड & हॉस्पिटैलिटी
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • गेस्ट हाउस
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • Property Management
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • धातु
    • फ़र्नीचर
    • फ़ूड
    • ब्रुअरी
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हार्डवेयर & सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • साफ-सफाई से जुड़ी सेवाएं
    • HVAC सर्विस
    अन्य
    • गैर-लाभकारी संगठन
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    सभी इंडस्ट्री को ब्राउज़ करें
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
सहायता

Menu dropdown_click outside to collapse

Subscribe

Get notified when there's activity on this post

This question has been flagged
odooodoo11odoo11communityodoo11.0Odoo11
3 Replies
11113 डेटा देखने का तरीका
अवतार
Gulshan kumar krishnagiri
$(document).ready(function () {
$(document).click(function (event) {
var clickover = $(event.target);
var _opened = $(".navbar-top-collapse").hasClass("navbar-collapse navbar-top-collapse collapse in");
if (_opened === true && !clickover.hasClass("navbar-toggle collapsed")) {
$("button.navbar-toggle collapsed").click();
}
});
});



This seems not working for me. Any leads if possible.
0
अवतार
खारिज करें
अवतार
faOtools
Best Answer

Hi, 

add a a logger to make sure that elements you search are found and they are what you search for:

console.log("clickover: ", clickover, "_opened: ", _opened);

My assumption is that it is not so: e.g. 'clickover' would ever hardly have the searched class, since event relates to a 'document', not your dropdown.

Finally, the issue you are trying to solve is quite controversial, you should be really cautious of extending outside Odoo standard js. Have a look here: https://stackoverflow.com/questions/152975/how-do-i-detect-a-click-outside-an-element. 

UPDATE

try this code:

    $(document).ready(function () {
        $(document).click(function (event) {
            event.stopPropagation();
            var thisButton = $(document).find('.navbar-collapse navbar-top-collapse collapse in');
            console.log("thisButton", thisButton);
            thisButton.removeClass("collapse");
        });
    });
in the last string put the class which is responsible for beeing expanded
0
अवतार
खारिज करें
अवतार
Gulshan kumar krishnagiri
लेखक Best Answer

Thank you. 

I used this logger and i get this error :

collapse_menu.js:13 Uncaught ReferenceError: clickover is not defined


Comment 2: 

I did this - Thanks.

Console: 

payment_form.js:459 DOM doesn't contain '.o_payment_form'

tour_manager.js:170 Tour Manager is ready.  running_tour=null

collapse_menu.js:9 clickover:  jQuery.fn.init [div.w-toggle-menu, context: div.w-toggle-menu]0: div.w-toggle-menucontext: div.w-toggle-menulength: 1__proto__: Object(0) _opened:  false

collapse_menu.js:20 clickover:  jQuery.fn.init [div.w-toggle-menu, context: div.w-toggle-menu]0: div.w-toggle-menucontext: div.w-toggle-menulength: 1__proto__: Object(0) _opened:  false

collapse_menu.js:32 clickover:  jQuery.fn.init [div.w-toggle-menu, context: div.w-toggle-menu]0: div.w-toggle-menucontext: div.w-toggle-menulength: 1__proto__: Object(0) _opened:  false


Do i need to do something else as well? Because the menu dropdown is not closing when i click outside. And the _opened: is always false.

0
अवतार
खारिज करें
faOtools

you should add it after defining the var (before 'if'). clickover is definitely inside your method - 'var clickover ='

Gulshan kumar krishnagiri
लेखक

payment_form.js:459 DOM doesn't contain '.o_payment_form'

tour_manager.js:170 Tour Manager is ready. running_tour=null

collapse_menu.js:9 clickover: jQuery.fn.init [div.w-toggle-menu, context: div.w-toggle-menu]0: div.w-toggle-menucontext: div.w-toggle-menulength: 1__proto__: Object(0) _opened: false

collapse_menu.js:20 clickover: jQuery.fn.init [div.w-toggle-menu, context: div.w-toggle-menu]0: div.w-toggle-menucontext: div.w-toggle-menulength: 1__proto__: Object(0) _opened: false

collapse_menu.js:32 clickover: jQuery.fn.init [div.w-toggle-menu, context: div.w-toggle-menu]0: div.w-toggle-menucontext: div.w-toggle-menulength: 1__proto__: Object(0) _opened: false

Do i need to do something else as well? Because the menu dropdown is not closing when i click outside. And the _opened: is always false.

Gulshan kumar krishnagiri
लेखक

This is my .js file:

odoo.define('theme_wibas.collapseMenu', function (require) {

'use strict';

$(document).ready(function () {

$(document).click(function (event) {

var clickover = $(event.target);

var _opened = $(".navbar-top-collapse").hasClass("navbar-collapse navbar-top-collapse collapse in");

console.log("clickover: ", clickover, "_opened: ", _opened);

if (_opened === true && !clickover.hasClass("navbar-toggle collapsed")) {

$("button.navbar-toggle collapsed").click();

}

});

});

faOtools

It means that selector $(".navbar-top-collapse") ie either not found or doesn't have a searched class. Besides, I guess what you do in 'if' is not correct, since the second part would be always true. It is better to use removeClass which will check for class by itself. I updated my initial answer - try to use it.

Gulshan kumar krishnagiri
लेखक

odoo.define('theme_wibas.collapseMenu', function (require) {

'use strict';

$(document).ready(function () {

$(document).click(function (event) {

event.stopPropagation();

var thisButton = $(document).find('.o_dropdown_toggler_btn');

console.log("thisButton", thisButton);

thisButton.removeClass(".navbar-toggle");

});

});

Doesn't work... :(

faOtools

var thisButton = $(document).find('.navbar-collapse navbar-top-collapse collapse in');

Gulshan kumar krishnagiri
लेखक

$(document).ready(function () {

$(document).click(function (event) {

event.stopPropagation();

var thisButton = $(document).find('.navbar-collapse navbar-top-collapse collapse in');

console.log("thisButton", thisButton);

thisButton.removeClass(".navbar-toggle");

// thisButton.removeClass(".navbar-toggle collapsed");

});

});

Nope. Its still the same...

faOtools

and what is logged by console.log("thisButton", thisButton)?

Gulshan kumar krishnagiri
लेखक

thisButton jQuery.fn.init [prevObject: jQuery.fn.init(1), context: document, selector: ".navbar-collapse navbar-top-collapse collapse in"]context: documentlength: 0prevObject: jQuery.fn.init [document, context: document]selector: ".navbar-collapse navbar-top-collapse collapse in"__proto__: Object(0)

faOtools

So, length of found items is zero. It means that no elements with the class navbar-collapse navbar-top-collapse collapse in are on the document. Double check that you have an element with such a class

Gulshan kumar krishnagiri
लेखक

Ok will post all details:

1. When i click on the menu :

<button id="mainmenubutton" type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-top-collapse">

<div class="w-toggle-menu">Menü</div>

<div class="w-toggle-close">×</div>

<div class="w-toggle-hamburger">

<span class="icon-bar"></span>

<span class="icon-bar"></span>

<span class="icon-bar"></span>

</div>

</button>

2. the the dropdown list code:

<div class="navbar-collapse navbar-top-collapse collapse in" aria-expanded="true" style="">

<ul class="nav navbar-nav navbar-left" id="top_menu">

<li>

<a href="/unternehmen">

<span data-oe-model="website.menu" data-oe-id="19" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">(f) Unternehmen</span>

</a>

</li>

<li>

<a href="/digitalisierung">

<span data-oe-model="website.menu" data-oe-id="15" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Digitalisierung</span>

</a>

</li>

<li>

<a href="/agile-organisation">

<span data-oe-model="website.menu" data-oe-id="7" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Agile Organisation</span>

</a>

</li>

<li>

<a href="/scaled-agile">

<span data-oe-model="website.menu" data-oe-id="24" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Scaled Agile</span>

</a>

</li>

<li>

<a href="/agile-methoden">

<span data-oe-model="website.menu" data-oe-id="22" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Agile Methoden</span>

</a>

</li>

<li>

<a href="/beratung">

<span data-oe-model="website.menu" data-oe-id="11" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Beratung</span>

</a>

</li>

<li>

<a href="/schulungen">

<span data-oe-model="website.menu" data-oe-id="9" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Schulungen</span>

</a>

</li>

<li>

<a href="/veranstaltungen">

<span data-oe-model="website.menu" data-oe-id="4" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Veranstaltungen</span>

</a>

</li>

<li>

<a href="/publikationen">

<span data-oe-model="website.menu" data-oe-id="5" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Publikationen</span>

</a>

</li>

<li>

<a href="/topicpage">

<span data-oe-model="website.menu" data-oe-id="38" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Topicpage</span>

</a>

</li>

<li>

<a href="/scaled-agile-1">

<span data-oe-model="website.menu" data-oe-id="37" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Scaled-Agile</span>

</a>

</li>

<li>

<a href="/lotse">

<span data-oe-model="website.menu" data-oe-id="39" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">Ihr Lotse</span>

</a>

</li>

<li>

<a href="/gulshan">

<span data-oe-model="website.menu" data-oe-id="40" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">gulshan</span>

</a>

</li>

<li>

<a href="/test">

<span data-oe-model="website.menu" data-oe-id="41" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">test</span>

</a>

</li>

<li>

<a href="/test-1">

<span data-oe-model="website.menu" data-oe-id="42" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">test</span>

</a>

</li>

<li>

<a href="/gulshan-1">

<span data-oe-model="website.menu" data-oe-id="44" data-oe-field="name" data-oe-type="char" data-oe-expression="submenu.name">gulshan</span>

</a>

</li>

<li class="divider"></li>

<li data-oe-model="ir.ui.view" data-oe-id="1327" data-oe-field="arch" data-oe-xpath="/data/xpath[4]/div[1]/div[2]/div[1]/ul[1]/li[2]">

<form class="navbar-form navbar-left" role="search">

<div class="inner-addon right-addon">

<i class="fa fa-search"></i>

<input type="text" class="form-control" placeholder="Search">

</div>

<button type="submit" class="btn btn-default hidden">Submit</button>

</form>

</li>

<li class="lang-select">

<a class="js_change_lang" href="/en_US/?debug=assets" data-lang="en_US">

switch to english

</a>

</li>

</ul>

</div>

Gulshan kumar krishnagiri
लेखक

Any help? I tried out every possible thing.

Gulshan kumar krishnagiri
लेखक

Hey Guys - The solution is this. This worked fine.

$(document).click(function (event) {

var clickover = $(event.target);

var $navbar = $(".navbar-top-collapse");

var _opened = $navbar.hasClass("in");

if (_opened === true && !clickover.hasClass("navbar-toggle collapsed")) {

$navbar.collapse('hide');

}

});

अवतार
faOtools
Best Answer

Hi, 

add a a logger to make sure that elements you search are found and they are what you search for:

console.log("clickover: ", clickover, "_opened: ", _opened);

My assumption is that it is not so: e.g. 'clickover' would ever hardly have the searched class, since event relates to a 'document', not your dropdown.

Finally, the issue you are trying to solve is quite controversial, you should be really cautious of extending outside Odoo standard js. Have a look here: https://stackoverflow.com/questions/152975/how-do-i-detect-a-click-outside-an-element. 

0
अवतार
खारिज करें
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

साइन अप करें
Related Posts Replies डेटा देखने का तरीका ऐक्टिविटी
Odoo 11 Hide EDIT & DELETE Solved
odoo odoo11 odoo11community odoo11.0
अवतार
अवतार
1
मार्च 21
5222
Odoo Date Total In Version 11 Solved
odoo11 odoo11community odoo11.0 Odoo11
अवतार
अवतार
अवतार
3
मार्च 19
5461
how to pass element tree to other function TypeError: 'ElementTree' object is not iterable - - -
odoo11 odoo12.0 odoo11community odoo11.0 Odoo11
अवतार
अवतार
1
मई 20
8656
Hide field using One2many domain Solved
domain odoo11 odoo11community odoo11.0 Odoo11
अवतार
अवतार
1
जन॰ 19
8042
issue (Uncaught TypeError: Cannot read property 'toggleClass' of undefined) with odoo in latest update of chrome
odoo11 odoov11 odoo11community odoo11.0 Odoo11
अवतार
0
नव॰ 18
7294
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now