【问题标题】:MVC ajax dynamic dropdownlistMVC ajax 动态下拉列表
【发布时间】:2014-08-15 06:42:24
【问题描述】:

是否有使用 ajax 作为下拉列表的示例。我想预加载下拉列表以便从中进行选择,但也希望能够键入下拉列表字段以进行搜索并使其列出匹配的项目。

请提供示例链接,或发布示例代码。

【问题讨论】:

    标签: ajax asp.net-mvc html.dropdownlistfor


    【解决方案1】:

    你可以使用非常强大的插件:Chosenplagin。 你的例子:

    $('choices input').autocomplete({
      source: function( request, response ) {
        $.ajax({
          url: "/autocomplete/Controller"+request.term+"/",
          dataType: "json",
          beforeSend: function(){$('ul.chzn-results').empty();},
          success: function( data ) {
            response( $.map( data, function( item ) {
              $('ul.chzn-results').append('<li class="active-result">' + item.name + '</li>');
            }));
          }
        });
      }
    });
    

    【讨论】:

      【解决方案2】:

      您可以使用 J-Query 的自动完成功能请参阅下面的链接了解其示例实现..

      http://basiccodeexample.blogspot.in/search?q=AutoComplete

      或者您可以使用 datalist html5 标签在下面的链接中找到参考

      http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_datalist

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-09-08
        • 2015-05-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-22
        • 1970-01-01
        相关资源
        最近更新 更多