Programmatically Set JQuery Mobile slider value
===

How do I programmatically set the value of a slider in JQuery mobile? I have the following slider defined:

    <label for="optionSlider">Are you sure?</label>
    <select id="optionSlider" name="slider" data-role="slider">
      <option value="no">No</option>
      <option value="yes">Yes</option>
    </select>

When the page is shown, I want to set it to "yes". I know that I can use the "selected" attribute, but because the value will be dynamic,I need to figure out how to set it programmatically. Currently, I'm using the following:

    $("#myPage").live("pageshow", function () {
      var flag = "yes"
      if ((flag != null) && (flag != undefined)) {
        if (isTrackSet == "no") {
          $("#optionSlider", "#myPage").val("no");
        } else {
          $("#optionSlider", "#myPage").val("yes");
        }
      }
    }


What am I doing wrong?