0

The following code snippet which includes an onClick event will not work until I click reload on both the simulator and the phone. The code is in an .erb file in an app model folder.

<section id="page1" data-role="page">
 <header data-role="header">
   <h1>CSS 3 Animations</h1>
 </header>
 <div data-role="content" class="content">
   <p class="show-menu" onclick="ToggleText()">(Show/Hide) Menu</p>

   <div class="sliding-menu slide out">Menu</div>
 </div>
</section>

<script type="text/javascript">
   function ToggleText() {
       $(".sliding-menu").toggleClass("reverse out in");
   }
</script>

I'm using rhomobile 3.2.1 with. Can someone explain why and what to do to fix it?

basheps
  • 10,034
  • 11
  • 36
  • 45

2 Answers2

0

Would something like this work?

JS

$('.toggle-menu').click(function() {
    $(".sliding-menu").toggleClass("reverse out in");
});

HTML

<section id="page1" data-role="page">
    <header data-role="header">
        <h1>CSS 3 Animations</h1>
    </header>
    <div data-role="content" class="content">
        <p class="toggle-menu">(Show/Hide) Menu</p>

        <div class="sliding-menu slide out">Menu</div>
    </div>
</section>
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
0

Just a guess, try defining the function before it is invoked?

nan
  • 4,238
  • 4
  • 25
  • 24