How to get responsive navbar menu to automatically close after anchor link clicked?

UrielG
20 Posts
UrielG posted this 31 December 2015

Hello,

I have a one-page layout for my homepage. It has several sections with anchors and the main menu items pointing out to those anchors down that same page. Now, when a link is clicked from the submenu of the responsive navbar icon menu, it stays open.

Is there any config that allows the responsive menu to be closed just after a click has been produced to anchor locations in the same page?

Uriel Guerrero

Hello, I have a one-page layout for my homepage. It has several sections with anchors and the main menu items pointing out to those anchors down that same page. Now, when a link is clicked from the submenu of the responsive navbar icon menu, it stays open. Is there any config that allows the responsive menu to be closed just after a click has been produced to anchor locations in the same page? Uriel Guerrero

Last edited 31 December 2015 by UrielG

Vote to pay developers attention to this features or issue.
15 Comments
Order By: Standard | Newest
Support Team
Support Team posted this 01 January 2016

Hello Uriel,
unfortunately there's no solution for this issue.
It happens because the menu closes when page is reloaded. But with one page design the page is not reloaded when you're navigating between anchors.

Regards,
Aileen

Hello Uriel, unfortunately there's no solution for this issue. It happens because the menu closes when page is reloaded. But with one page design the page is not reloaded when you're navigating between anchors. Regards, Aileen
jrgweb
26 Posts
jrgweb posted this 01 January 2016

Hey Uriel,

Try adding this to the bottom of your index file.
This has NOT been tested with Themler but I use it
for pure bootstrap themes.

<script>
$(document).on('click','.navbar-collapse.in',function(e) {

if( $(e.target).is(&#39;a&#39;) &amp;&amp; ( $(e.target).attr(&#39;class&#39;) != &#39;dropdown-toggle&#39; ) ) {
    $(this).collapse(&#39;hide&#39;);
}

});
</script>

James G.

Hey Uriel, Try adding this to the bottom of your index file. This has NOT been tested with Themler but I use it for pure bootstrap themes. &lt;script&gt; $(document).on(&#39;click&#39;,&#39;.navbar-collapse.in&#39;,function(e) { if( $(e.target).is(&#39;a&#39;) &amp;&amp; ( $(e.target).attr(&#39;class&#39;) != &#39;dropdown-toggle&#39; ) ) { $(this).collapse(&#39;hide&#39;); } }); &lt;/script&gt; James G.
UrielG
20 Posts
UrielG posted this 04 January 2016

@James thanks for the suggestion man. It did not work. I will use an external plugin to solve the issue.

@Aileen I think this issue could be taken as propose for the development of Themler, as a feature to be included in future versions.

Hey, happy new year!

Hey Uriel,

Try adding this to the bottom of your index file.
This has NOT been tested with Themler but I use it
for pure bootstrap themes.

<script>
$(document).on('click','.navbar-collapse.in',function(e) {

if( $(e.target).is(&#39;a&#39;) &amp;&amp; ( $(e.target).attr(&#39;class&#39;) != &#39;dropdown-toggle&#39; ) ) {
    $(this).collapse(&#39;hide&#39;);
}

});
</script>

James G.

@James thanks for the suggestion man. It did not work. I will use an external plugin to solve the issue. @Aileen I think this issue could be taken as propose for the development of Themler, as a feature to be included in future versions. Hey, happy new year! > Hey Uriel, > > Try adding this to the bottom of your index file. > This has NOT been tested with Themler but I use it > for pure bootstrap themes. > > &lt;script&gt; > $(document).on(&#39;click&#39;,&#39;.navbar-collapse.in&#39;,function(e) { > > if( $(e.target).is(&#39;a&#39;) &amp;&amp; ( $(e.target).attr(&#39;class&#39;) != &#39;dropdown-toggle&#39; ) ) { > $(this).collapse(&#39;hide&#39;); > } > > }); > &lt;/script&gt; > > James G.
UrielG
20 Posts
UrielG posted this 06 January 2016

Hello again colleagues,

I have been trying with some menu plugins, but for those I have tested, none of them bring together the features I need.

The best option regardless of the missing function presented here, is to keep using the menu control from Themler. Now, I'm reviving this thread in order to reopen the option for suggestions like the one @James G has presented earlier.

Does anyone know a tested solution to be applied externally (in the theme code) to get working the needed behavior for the menu?

Hello again colleagues, I have been trying with some menu plugins, but for those I have tested, none of them bring together the features I need. The best option regardless of the missing function presented here, is to keep using the menu control from Themler. Now, I'm reviving this thread in order to reopen the option for suggestions like the one @James G has presented earlier. Does anyone know a tested solution to be applied externally (in the theme code) to get working the needed behavior for the menu?

Last edited 06 January 2016 by UrielG

jrgweb
26 Posts
jrgweb posted this 07 January 2016

Hey Uriel
One of the 2 scripts below should work. Again, I have not tested in themler. In prior message when I pasted the script, it pasted incorrectly.

<script>
$('.navbar-collapse ul li a').click(function() {
$('.navbar-toggle:visible').click();
});</script>

<script>$(document).on('click','.navbar-collapse.in',function(e) {
if( $(e.target).is('a') && ( $(e.target).attr('class') != 'dropdown-toggle' ) ) {
$(this).collapse('hide');
}
});</script>

Are you using in a CMS?

James

Hey Uriel One of the 2 scripts below should work. Again, I have not tested in themler. In prior message when I pasted the script, it pasted incorrectly. &lt;script&gt; $(&#39;.navbar-collapse ul li a&#39;).click(function() { $(&#39;.navbar-toggle:visible&#39;).click(); });&lt;/script&gt; &lt;script&gt;$(document).on(&#39;click&#39;,&#39;.navbar-collapse.in&#39;,function(e) { if( $(e.target).is(&#39;a&#39;) &amp;&amp; ( $(e.target).attr(&#39;class&#39;) != &#39;dropdown-toggle&#39; ) ) { $(this).collapse(&#39;hide&#39;); } });&lt;/script&gt; Are you using in a CMS? James
UrielG
20 Posts
UrielG posted this 07 January 2016

Hi James,

Yes, I'm using Themler to build a theme for WordPress. I tried with both scripts within the index.php and then in the page.php files of the theme. None of the possible mixes worked.

I think there should be a little code trick for solving this simple issue while Themler developers add the feature.

Hi James, Yes, I'm using Themler to build a theme for WordPress. I tried with both scripts within the index.php and then in the page.php files of the theme. None of the possible mixes worked. I think there should be a little code trick for solving this simple issue while Themler developers add the feature.
truptisdesale
1 Posts
truptisdesale posted this 19 January 2017

Try this
$('.navbar-collapse ul li a').click(function(){
$('.navbar-toggle:visible').click();
});

worked for me.

Try this $('.navbar-collapse ul li a').click(function(){ $('.navbar-toggle:visible').click(); }); worked for me.
mahalemohan1
1 Posts
mahalemohan1 posted this 15 July 2017

Try this
$('.navbar-collapse ul li a').click(function(){
$('.navbar-toggle:visible').click();
});

worked for me.

@truptisdesale thanks. it was also worked for me.

> Try this > $('.navbar-collapse ul li a').click(function(){ > $('.navbar-toggle:visible').click(); > }); > > worked for me. @truptisdesale thanks. it was also worked for me.
mburgener
26 Posts
mburgener posted this 22 August 2017

actually, where have you put the code snippet in?

actually, where have you put the code snippet in?
Gianluigi Giorgetti
1 Posts
Gianluigi Giorgetti posted this 30 August 2017

Ok, here is my solution:
I added in the additional head html code space in Themler->Home->Settings the following code

<script type="text/javascript">
 jQuery( document ).ready(function() {
    jQuery('.navbar-collapse a').click(function(){ 
      jQuery('.navbar-collapse').css('height', '0');
      jQuery('.navbar-collapse').removeClass('in');
    });  
 });
</script>

worked perfectly
enjoy
Gianni

Ok, here is my solution: I added in the additional head html code space in Themler->Home->Settings the following code <script type="text/javascript"> jQuery( document ).ready(function() { jQuery('.navbar-collapse a').click(function(){ jQuery('.navbar-collapse').css('height', '0'); jQuery('.navbar-collapse').removeClass('in'); }); }); </script> worked perfectly enjoy Gianni
mburgener
26 Posts
mburgener posted this 23 January 2018

this workaround worked like a charm! thanks!

this workaround worked like a charm! thanks!
Web IT Solutions LLP
378 Posts
Web IT Solutions LLP posted this 30 June 2019

Ok, here is my solution:
I added in the additional head html code space in Themler->Home->Settings the following code

worked perfectly
enjoy
Gianni

Hello Sir,

Any solutions for my Off-Canvas RTL Direction please ?

https://answers.themler.io/questions/188820/off-canvas-direction-right-to-left?page=1

Regards
Suffian Ahmed

> Ok, here is my solution: > I added in the additional head html code space in Themler->Home->Settings the following code > > > > worked perfectly > enjoy > Gianni Hello Sir, Any solutions for my Off-Canvas RTL Direction please ? https://answers.themler.io/questions/188820/off-canvas-direction-right-to-left?page=1 Regards Suffian Ahmed
marcin8
9 Posts
marcin8 posted this 04 March 2022

Thank you so much for the above solution, it works perfectly :)

Thank you so much for the above solution, it works perfectly :)
jen123cruz123
4 Posts
jen123cruz123 posted this 18 August 2023

To achieve the desired behavior of automatically closing the responsive navbar menu after a link is clicked and the page scrolls to the anchor location, you can use JavaScript/jQuery.

Cheers,
Jen @ drywall companies near me atlanta

To achieve the desired behavior of automatically closing the responsive navbar menu after a link is clicked and the page scrolls to the anchor location, you can use JavaScript/jQuery. Cheers, Jen @ [drywall companies near me atlanta][1] [1]: https://atlanta-drywall-contractor-gurus.business.site/?m=true
greatvalue098
2 Posts
greatvalue098 posted this 29 April 2026

https://www.fairyabc.com/home.php?mod=space&uid=116106
https://www.malaysialistings.com/listings/great-value-brand
https://www.daddycow.com/topics/view/10045
https://linktr.ee/greatvalues
https://data.world/greatvalue098
https://myanimelist.net/profile/greatv2
https://www.mixcloud.com/greatvalue098/
https://sketchfab.com/JacksonMike2
https://openlibrary.org/people/great_value
https://steemit.com/greatvalue/@fainamiller/discover-quality-and-savings-with-great-value-goods
https://groups.google.com/g/great-value-brand
https://www.magcloud.com/user/greatvalue1
https://glass-sock-ae9.notion.site/Stock-Up-on-Great-Value-Biscuits-for-Tasty-Family-Moments-Ahead-3423535ab01c8067ae5ec4c4a6370a78?pvs=73
https://slides.com/d/jrwvKr8/speaker/sjASqww
https://www.walkscore.com/people/332494547115/walk-score-user
https://greatvalue.exposure.co/
https://devfolio.co/@greatvalue098/readme-md
https://www.designspiration.com/greatvalue098/saves/
https://leetcode.com/u/greatvalue09/
https://community.intercom.com/apps-integrations-25/handling-empty-datetime-variable-in-custom-action-to-prevent-failure-14139?postid=37798#post37798
https://greatvalue.mypixieset.com/
https://www.instapaper.com/p/17624172
https://savee.com/greatvalue098/
https://webyourself.eu/blogs/1908681/Great-Value-Pantry-Staples-for-Budget-Friendly-Meals
https://metaldevastationradio.com/greatv2
https://all4.vip/p/page/view-persons-profile?id=122215
https://co-roma.openheritage.eu/profiles/_2187/activity
https://log.concept2.com/profile/2922201
https://stocktwits.com/greatv2
https://www.proko.com/@great_value/activity
https://experiment.com/users/jmike
https://greatvalue.gumroad.com/?_gl=1131qitz_ga*NTI4ODEyNTI1LjE3NzY2ODc3MDk.*_ga_6LJN6D94N6*czE3NzY2ODc3MDgkbzEkZzEkdDE3NzY2ODc3NTAkajE4JGwwJGgw
https://www.intensedebate.com/people/gvalue52
https://fueler.io/greatvalue01
https://www.getlisteduae.com/listings/great-value-brand
https://land-book.com/great_value_156059
https://www.whizolosophy.com/category/choices-decisions/article-essay/shop-great-value-products-for-everyday-savings-and-quality
https://pinshape.com/users/8953614-greatvalue098?tab=designs
https://www.freelistingaustralia.com/listings/great-value-brand
https://review.stylevore.com/great-value-brand/
https://greatvalue.start.page/
https://www.wantoask.com/user/greatvalue
https://eilo.org/user/greatv2
https://soundcloud.com/william-776077966/great-value-podcast
https://hypothes.is/users/greatv21
https://listen.hubhopper.com/episode/great-value-podcast/33001494?s=hh-web-app
https://www.yumpu.com/user/greatvalue098
https://www.freelistingusa.com/listings/great-value-brand
https://creators.spotify.com/pod/profile/wild-fab2/episodes/Great-Value-Brand-Products-e3id9kt/a-ack4at6
https://issuu.com/greatvalue0
https://www.spreaker.com/episode/great-value-podcast--71611121
https://www.speedrun.com/users/greatv21
https://solo.to/greatv
https://www.techrepublic.com/forums/discussions/fixing-slow-boot-app-lag-on-windows-11/#post-4356843
https://gravatar.com/scrumptiously205f03bc7d
https://www.tkaraoke.com/forums/profile/greatvalue098gmail-com/
https://www.myminifactory.com/users/greatvalue
https://hearthis.at/great-value/great-value-podcast/
https://www.ewebdiscussion.com/threads/13-unexpected-health-benefits-of-pineapple-juice.24937/
https://pastelink.net/wxw4kcke

https://www.fairyabc.com/home.php?mod=space&uid=116106 https://www.malaysialistings.com/listings/great-value-brand https://www.daddycow.com/topics/view/10045 https://linktr.ee/greatvalues https://data.world/greatvalue098 https://myanimelist.net/profile/greatv2 https://www.mixcloud.com/greatvalue098/ https://sketchfab.com/JacksonMike2 https://openlibrary.org/people/great_value https://steemit.com/greatvalue/@fainamiller/discover-quality-and-savings-with-great-value-goods https://groups.google.com/g/great-value-brand https://www.magcloud.com/user/greatvalue1 https://glass-sock-ae9.notion.site/Stock-Up-on-Great-Value-Biscuits-for-Tasty-Family-Moments-Ahead-3423535ab01c8067ae5ec4c4a6370a78?pvs=73 https://slides.com/d/jrwvKr8/speaker/sjASqww https://www.walkscore.com/people/332494547115/walk-score-user https://greatvalue.exposure.co/ https://devfolio.co/@greatvalue098/readme-md https://www.designspiration.com/greatvalue098/saves/ https://leetcode.com/u/greatvalue09/ https://community.intercom.com/apps-integrations-25/handling-empty-datetime-variable-in-custom-action-to-prevent-failure-14139?postid=37798#post37798 https://greatvalue.mypixieset.com/ https://www.instapaper.com/p/17624172 https://savee.com/greatvalue098/ https://webyourself.eu/blogs/1908681/Great-Value-Pantry-Staples-for-Budget-Friendly-Meals https://metaldevastationradio.com/greatv2 https://all4.vip/p/page/view-persons-profile?id=122215 https://co-roma.openheritage.eu/profiles/_2187/activity https://log.concept2.com/profile/2922201 https://stocktwits.com/greatv2 https://www.proko.com/@great_value/activity https://experiment.com/users/jmike https://greatvalue.gumroad.com/?_gl=1*131qitz*_ga*NTI4ODEyNTI1LjE3NzY2ODc3MDk.*_ga_6LJN6D94N6*czE3NzY2ODc3MDgkbzEkZzEkdDE3NzY2ODc3NTAkajE4JGwwJGgw https://www.intensedebate.com/people/gvalue52 https://fueler.io/greatvalue01 https://www.getlisteduae.com/listings/great-value-brand https://land-book.com/great_value_156059 https://www.whizolosophy.com/category/choices-decisions/article-essay/shop-great-value-products-for-everyday-savings-and-quality https://pinshape.com/users/8953614-greatvalue098?tab=designs https://www.freelistingaustralia.com/listings/great-value-brand https://review.stylevore.com/great-value-brand/ https://greatvalue.start.page/ https://www.wantoask.com/user/greatvalue https://eilo.org/user/greatv2 https://soundcloud.com/william-776077966/great-value-podcast https://hypothes.is/users/greatv21 https://listen.hubhopper.com/episode/great-value-podcast/33001494?s=hh-web-app https://www.yumpu.com/user/greatvalue098 https://www.freelistingusa.com/listings/great-value-brand https://creators.spotify.com/pod/profile/wild-fab2/episodes/Great-Value-Brand-Products-e3id9kt/a-ack4at6 https://issuu.com/greatvalue0 https://www.spreaker.com/episode/great-value-podcast--71611121 https://www.speedrun.com/users/greatv21 https://solo.to/greatv https://www.techrepublic.com/forums/discussions/fixing-slow-boot-app-lag-on-windows-11/#post-4356843 https://gravatar.com/scrumptiously205f03bc7d https://www.tkaraoke.com/forums/profile/greatvalue098gmail-com/ https://www.myminifactory.com/users/greatvalue https://hearthis.at/great-value/great-value-podcast/ https://www.ewebdiscussion.com/threads/13-unexpected-health-benefits-of-pineapple-juice.24937/ https://pastelink.net/wxw4kcke
You must log in or register to leave comments