延迟加载SELECT元素选项w / jquerymobile,c#和asp.net

我的一个jQuery Mobile页面上有一个SELECT元素,它有很多可能的值。显然,在页面加载时加载所有选项会增加移动手机的性能问题。什么是“按需”加载项目的好方法? 我需要的一个例子是Android市场如何加载应用程序列表:最初加载x个项目,然后在滚动到选项底部后再加载x个项目,然后x更多......依此类推)。 我正在使用C#/ ASP.NET(Razor语法)来实现jQuery Mobile。     
已邀请:
这是我的解决方案。这个想法是实现一种类似Twitter的分页,你应该从一开始就做出一些选择。
<div data-role="page">

    <div data-role="header">
        <h1>Page Title</h1>
    </div><!-- /header -->

    <div data-role="content">   
        <p>Page content goes here.</p>

        <div data-role="fieldcontain">
            <label for="select-choice-1" class="select">Choose shipping method:</label>
            <select name="select-choice-1" id="select-choice-1">
                <option value="standard">Standard: 7 day</option>
                <option value="rush">Rush: 3 days</option>
                <option value="express">Express: next day</option>
                <option value="overnight">Overnight</option>
                <option value="-1">More...</option>
            </select>
        </div>

        </div><!-- /content -->

    <div data-role="footer">
        <h4>Page Footer</h4>
    </div><!-- /footer -->
</div><!-- /page -->
然后将一些处理程序挂钩到More选项
<script type="text/javascript">
    $(document).bind("pageshow", function(){
        bindMore();
    });

    function bindMore(){
        // The rendered select menu will add "-menu" to the select id
        $("#select-choice-1-menu li").last().click(function(e){handleMore(this, e)});
    }

    function handleMore(source, e){

        e.stopPropagation();

        var $this = $(source);

        $this.unbind();

        $this.find("a").text("Loading...");

        // Get more results
        $.ajax({
            url: "test.js",
            dataType: "script",
            success: function(data){
                $(eval(data)).each(function(){

                    // Add options to underlaying select
                    $("#select-choice-1 option").last()
                        .before($("<option></option>")
                        .attr("value", this.value)
                        .text(this.text)); 

                });

                // Refresh the selectmenu
                $('#select-choice-1').selectmenu('refresh');

                // Rebind the More button
                bindMore();

            }
        });
    }
</script>
Test.js包含这个:
[
        {"value": "1", "text": "1"},
        {"value": "2", "text": "2"},
        {"value": "3", "text": "3"}
]
    

要回复问题请先登录注册