displaying a default value in search area of a listview

displaying a default value in search area of a listview

Hello all,

I have a function that dynamically creates a list of timezones using jqm 1.3.2.

function tzSearch(tz, sName)
{
    $.post ("/Search", { "type":"tz" }, function(data)
    {
        var d = data.timezones;
        var catList = "<ul id='tzlist' data-role='listview' data-filter='true' data-filter-reveal='true' data-filter-placeholder='search timezone...' data-inset='true'>";
        $.each (d, function(i, item)
        {
            catList += "<li>";
            catList += item.tzone;
            catList += "</li>";
        });
        catList += "</ul>";
        $(sName).empty();
        $(sName).append(catList);
        $(sName).trigger("create");
    }, "json");
}

The user can search with autocomplete in the above list of timezones. I can display the selected timezone in the search box with the following code -

    $("#timezone").on("click", "li",  function () {
            var seltz = $(this).text();
            $(this).closest("ul").prev("form").find("input").val(seltz);
            $("#timezone li" ).addClass('ui-screen-hidden');

I am unable to figure out how to display a default timezone programmatically. So, in tzSearch (), I need to do something like this -

        $.each (d, function(i, item)
        {
            catList += "<li>";
            if (tz === item.tzone)
                  display it in the search area instead of asking user's input
            catList += item.tzone;
            catList += "</li>";
        });
 

and really ... does it have to be this difficult to set the input value?
            $(this).closest("ul").prev("form").find("input").val(seltz);