JQM 1.4.3 everything about flip switches does not work for me

JQM 1.4.3 everything about flip switches does not work for me

To whom it may concern,

I'm testing out the flip switch feature of JQM 1.4.3 but for some reason everything I know about them data-wise is not working for me.

What I'm testing is on flip switch change, I want to get the current value, but no matter how many times I change the flip switch, the value does not match the state displayed.

I'm also trying to toggle the flip switch on a button press. Value wise, it is toggling between on and off but the flip switch does not show the correct state even after calling the refresh method recommended from the JQM 1.4.3 API documentations.

The documentations for refreshing a flip switch that I'm looking at is: link

My HTML code:
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <title>Flip switch test</title>
  6.   
  7.   <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.css" />
  8.   <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
  9.   <script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"></script>
  10.     
  11. </head>
  12. <body>

  13.   <div data-role="page" class="myPage">
  14.     <a data-role="button" class="toggleFlipswitchBTN" data-inline="true">TOGGLE FLIP</a>
  15.     <input type="checkbox" data-role="flipswitch" class="flipswitchTest" data-on-text="Online" data-off-text="Offline" data-wrapper-class="flipswitchTestWrapper" />
  16.   </div>

  17. </body>
  18. </html>

My JavaScript code:
  1. $(document).on("pagebeforecreate", ".myPage", function(){
  2.   $(".toggleFlipswitchBTN").on("click", toggleFlipSwitch);
  3.   $(".flipswitchTest").on("change",flipswitchChange);
  4. });

  5. function toggleFlipSwitch(){
  6.   var currentStatus = $(".flipswitchTest").val();
  7.   var toggleTo = {
  8.     "on" : "off",
  9.     "off": "on"
  10.   };
  11.   var toggleToStatus = toggleTo[currentStatus];
  12.   alert("CURRENTLY: " + currentStatus + " CHANGING TO " + toggleToStatus);
  13.   $(".flipswitchTest").val(toggleToStatus).flipswitch("refresh");
  14. }//toggleFlipSwitch
  15.   
  16. function flipswitchChange(e){
  17.   var currentStatus = $(".flipswitchTest").val();
  18.   alert("FLIPSWITCH CHANGED TO: " + currentStatus);
  19. }
My CSS code:
  1. .flipswitchTestWrapper.ui-flipswitch .ui-btn.ui-flipswitch-on {
  2.   text-indent: -3.6em;
  3. }
  4. .flipswitchTestWrapper.ui-flipswitch .ui-flipswitch-off {
  5.   text-indent: 0.3em;
  6. }

I've made a JS Bin example which can be found at: link

The HTML and CSS coding is basically a copy and paste from the demo source for flipswitch found at: link

Can someone please help explain to me what I'm doing wrong and if possible, the correct methods.

Thank you.