Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不在局部视图中工作的样式和脚本_C#_Jquery_Css_Asp.net Mvc_Asp.net Mvc Partialview - Fatal编程技术网

C# 不在局部视图中工作的样式和脚本

C# 不在局部视图中工作的样式和脚本,c#,jquery,css,asp.net-mvc,asp.net-mvc-partialview,C#,Jquery,Css,Asp.net Mvc,Asp.net Mvc Partialview,我有一个局部视图(asp.netmvc),其中包含一些类为“select-select”的dropdownlist。但不知何故,这个课程没有得到应用。dropdownlist显示/样式为“正常” @using (var f = Html.Bootstrap().Begin(new Form("Home", "Index").FormMethod(FormMethod.Post).Type(FormType.Horizontal).InputWidthMd(12))) { @f.FormG

我有一个局部视图(
asp.netmvc
),其中包含一些类为“select-select”的
dropdownlist
。但不知何故,这个课程没有得到应用。
dropdownlist
显示/样式为“正常”

@using (var f = Html.Bootstrap().Begin(new Form("Home", "Index").FormMethod(FormMethod.Post).Type(FormType.Horizontal).InputWidthMd(12)))
{
    @f.FormGroup().DropDownListFor(model => model.Currency, Model.Currencies).Class("chosen-select")

    @f.FormGroup().ListBoxFor(model => model.CountryIds, Model.Countries).ShowValidationMessage(false).HtmlAttributes(new { @class = "chosen-select" })

    @f.FormGroup().ListBoxFor(model => model.USStateIds, Model.USStates).Id("usStates").ShowValidationMessage(false).HtmlAttributes(new { @class = "chosen-select" })

    @Html.Bootstrap().SubmitButton().Text(Resources.Form.Save).Class("btn btn-primary").HtmlAttributes(new { @style = "float:right;" })
}
局部视图
显示在对话框中

$(document).ready(function () {
        $('.chosen-select').chosen();
});
不确定它是否相关,但是jquery代码和样式放置在呈现此
部分视图的视图中。起初,它与
部分视图
位于同一页面上,但jquery代码和css样式似乎没有任何作用。这就是我重新定位它们的原因(也不确定这是否相关)


顺便说一句,我正在通过一个
AJAX
调用来呈现这个
部分视图。

也许问题在于,您在文档就绪时执行jQuery,然后在后面呈现部分视图AJAX,因此jQuery永远不会被应用。尝试执行此操作以初始化所选的:

$( document ).ajaxComplete(function() {
    $('.chosen-select').chosen();
});

也许问题在于,您正在对documentready执行jQuery,然后呈现部分视图AJAX afterwords,因此jQuery永远不会被应用。尝试执行此操作以初始化所选的:

$( document ).ajaxComplete(function() {
    $('.chosen-select').chosen();
});

在部分视图中的元素添加到页面后,对其调用
.selected()
。在部分视图中的元素添加到页面后,对其调用
.selected()!?干得好!这在我的剑道ui tabstrip(带引导)上起作用。在我调用ajaxComplete回调中的activateTab之前,我一直在使用奇怪的UI元素。太棒了,我怎么没有想到呢!?干得好!这在我的剑道ui tabstrip(带引导)上起作用。在我调用ajaxComplete回调中的activateTab之前,我一直在使用奇怪的UI元素。