Server sent event feedback to client

Server sent event feedback to client

Hi,

I am new to jQuery/jQuery Mobile and javascript programming.
I have a question about server sent events and jQuery Mobile:

Toggle slider html:
<li style="height: 40px;">
      <div class="containing-element">
            <label style="position: relative; top: 10px">Slider1</label>
            <span style="float: right">
                  <select name="Slider1" id="Slider1" onchange="SetBit('Val')" data-mini="true" data-role="slider">
                        <option value="off">Off</option>
                        <option value="on">On </option>
                  </select>
            </span>
      </div>
</li>
javascript server sent event:

if (typeof (EventSource) !== "undefined") {
      var source = new EventSource("TestEvents");
          source.onmessage = function (event) {
              var EventData = event.data.split("@");
              if (EventData[0] == "DateTime")
                  document.getElementById(EventData[0]).innerHTML = EventData[1] + "<br />";
              else {
                  if(EventData[1] == "1")
                        $('#Slider1').val('on').slider('refresh');
                  else
                        $('#Slider1').val('off').slider('refresh');
              }
          };
}
else {
    alert("Sorry, your browser does not support server-sent events...");
}

this function updates the time on the client side but does not update the toggle slider

What am I doing wrong?

Thank you
David