Tagged: x
-
AuthorPosts
-
January 18, 2017 at 1:13 am #1334630
kendrickaParticipantHi there,
I am using Edit Global Javascript to execute a couple of scripts, to expand and collapse the div content in some Archive widgets. Everything works well when I use an element selector, but as soon as I use $(this) the custom javascript window won’t save and my site has a gateway timeout 504 error.
This script works for each archive element:
jQuery(function($){
$(‘#nav_menu-8 h4’).click(function(){
$(‘#nav_menu-8 div’).toggleClass(‘show’);
});
});However, as the number of archives grow I want to write a one size fits all script, eg:
jQuery(function($){
$(‘.widget_nav_menu h4’).click(function(){
$(this).next(‘div’).toggleClass(‘show’);
//there will be another line here to collapse other open archives
});
});Bear in mind all my widgets have the same html structure, ie:
<div id=”#uniqueid” class=”widget_nav_menu”>
<h4>Archive name</h4>
<div>Hidden articles</div>
</div>Looks totally plausible and I’ve used this for other non-wp related jobs, but as soon as “(this)” is applied to the Global Javascript it breaks everything.
I hope you can help…
thanks,
AdrianJanuary 18, 2017 at 2:08 am #1334679
Paul RModeratorHi Adrian,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / passwordDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
January 18, 2017 at 5:39 pm #1335826
kendrickaParticipantThis reply has been marked as private.January 18, 2017 at 10:47 pm #1336187
RupokMemberHi Adrian,
Do you have more code to place on the Custom JS? In that case share the code here (don’t forget to wrap with code tag from Toolbar). I can see two blocks of code right now and seems working. Give us the code that’s not saving.
Cheers!
January 22, 2017 at 6:59 pm #1340903
kendrickaParticipantHi Rupok,
This is the code which wasn’t working. I have tested outside of wp and all seems fine with it.
I’d like this to *replace existing code* in the Global javascript section.
jQuery(function($){ $('.widget_nav_menu h4').click(function(){ $(this).next('div').toggle(); $(this).parent().siblings().children().next().hide(); }); });January 22, 2017 at 7:04 pm #1340904
kendrickaParticipantfalse alarm mate, I’ve just pasted this in and it’s behaving itself. Not sure what was wrong first time around…
Thanks
aJanuary 22, 2017 at 10:37 pm #1341033
Rue NelModeratorHello There,
Thanks for updating in! We’re just glad that you were able to figure out a way to resolve the issue.
If you have anything else we can help you with, please do not hesitate to create a separate thread.Regards.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1334630 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
