I have an issue when toggling a tablet from portrait to landscape and vice versa, the tablet doesn't reexecute jQuery codes.
Here is the scenario:
<div class="links">
  <ul class="hide">
    <li></li>
  </ul>
</div>
Initially, the ul element is hidden through CSS. Then I give this code to be opened on click event.
if ($(window).width() <= 800) { // portrait orientation
    $(".links").click(function() {
       $(this).find('ul').slideToggle();
    });
}
It works good so far. If I don't click anything, it still works fine even when I keep toggling to landscape back and forth. The issue comes when on portrait orientation, I click the element to open it and click it again to close.
It seems after the second click, the ul element got additional style="display:none" (initially this ain't there because it's handled by CSS). This is why the ul element got hidden when I switch back to landscape. Then I tried to give this code below.
if ($(window).width() > 800) { // landscape orientation
    if ($('.links ul').is(":hidden")) {
        $('.links ul').css("display","block");
    }
}
However, it seems this code never got executed whenever I switch to landscape orientation leaving the ul element hidden. Is there a work around so that the browser will execute code every time I toggle the orientation?