本文介绍了如何实现用“chosen.js”插件在MVC 3多重选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何实施插件MVC 3?

How to implement chosen plugin for MVC 3 ?

对于此类型的输出

推荐答案

我选择了重新配置如下插件和正常工作。

I have reconfigure chosen plugin as below and working properly.

我的剃须刀:

<div style="width: 750px; clear: both; margin-left: 170px;">

            @Html.ListBox(
                             "Emailaddress",
                             ViewBag.EmailaddressList as MultiSelectList,
                             new { @class = "chosen-select", data_placeholder = "Choose a Emailaddress...", style = "width:750px;", tabindex = "4" }
                         )
</div> 

您的HTML剃须刀code后加入这个剧本

Add this script after your html Razor code

<script src="@Url.Content("~/Scripts/chosen.js/chosen.jquery.js")" type="text/javascript"></script>
        <script type="text/javascript">
            var config = {
                '.chosen-select': {},
                '.chosen-select-deselect': { allow_single_deselect: true },
                '.chosen-select-no-single': { disable_search_threshold: 10 },
                '.chosen-select-no-results': { no_results_text: 'Oops, nothing found!' },
                '.chosen-select-width': { width: "95%" }
            }
            for (var selector in config) {
                $(selector).chosen(config[selector]);
            }
  </script>

我viewbag:

My viewbag :

ViewBag.Skills = new MultiSelectList(EmailaddressList, "Id", "EmailId");

这篇关于如何实现用“chosen.js”插件在MVC 3多重选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 21:27