0

有没有人自动完成工作?jquery 的示例代码(适用于 URL)我的操作被调用,但是没有值(null)被传递给操作???请帮助(http://jquerymobile.com/demos/1.3.0-rc.1/docs/demos/widgets/autocomplete/autocomplete-remote.html

<script>
        $( document ).on( "pageinit", "#myPage", function() {
            $( "#autocomplete" ).on( "listviewbeforefilter", function ( e, data ) {
                var $ul = $( this ),
                    $input = $( data.input ),
                    value = $input.val(),
                    html = "";
                $ul.html( "" );
                if ( value && value.length > 2 ) {
                    $ul.html( "<li><div class='ui-loader'><span class='ui-icon ui-icon-loading'></span></div></li>" );
                    $ul.listview( "refresh" );
                    $.ajax({
                        url:"@Url.Action("ClientSearch","Schedule")",,
                        dataType: "jsonp",
                        data: {
                            q: $input.val()
                        }
                    })
                    .then( function ( response ) {
                        $.each( response, function ( i, val ) {
                            html += "<li>" + val + "</li>";
                        });
                        $ul.html( html );
                        $ul.listview( "refresh" );
                        $ul.trigger( "updatelayout");
                    });
                }
            });
        });
    </script>

html

<div data-role="page" class="jqm-demos" id="myPage">
<ul id="autocomplete" data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Find a city..." data-filter-theme="d"></ul>
</div>
4

1 回答 1

0

好的,我找到了问题!它应该是:data: { term: $input.val()}

于 2013-03-28T20:00:24.913 回答