小编Rok*_*kal的帖子

有没有办法以编程方式强制IE8在新窗口而不是选项卡中打开弹出窗口?

有没有办法以编程方式指示IE8在新窗口而不是新选项卡中打开弹出窗口?我知道IE支持模态窗口,但我有一堆普通弹出窗口的遗留代码.

更新:

我正在使用Javascript的window.open()方法来创建弹出窗口.但是,当用户将其IE8设置设置为"始终在新选项卡中打开弹出窗口"时,弹出窗口将在新选项卡而不是新窗口中启动.

internet-explorer-8

9
推荐指数
1
解决办法
1万
查看次数

JQuery使用最近("element.class")

我试图找到最接近的tr,它也匹配特定的类名.选择器不返回任何匹配项.我不明白的是什么?

例如:

<table>
<tbody class="category" id="cat-1">
<tr class="category-head">
  <th>Category 1</th>
</tr>
  <tr class="category-item">
    <th>Item 1</th>
  </tr>
  <tr>
    <td>This is a description of category item 1</td>
  </tr>
  <tr>
    <td><input type="text" name="c1_i1_input" id="c1_i1_input" class="category-item-input" /></td>
  </tr>
   <tr class="category-item">
    <th>Item 2</th>
  </tr>
  <tr>
    <td>This is a description of category item 2</td>
  </tr>
  <tr>
    <td><input type="text" name="c1_i2_input" id="c1_i2_input" class="category-item-input" /></td>
  </tr>
  </tbody>
</table>

<script type="text/javascript">
    $(document).ready(function () {
        $(".category-item-input").change(function () {
           //this works, returning the closest tr
            alert($(this).closest("tr").html());

            //this returns null?
            alert($(this).closest("tr.category-item").html());
        });

    });</script>
Run Code Online (Sandbox Code Playgroud)

jquery jquery-selectors

3
推荐指数
1
解决办法
4951
查看次数

AutoMapper:如何仅映射匹配的属性名称而忽略所有其他属性?

我是AutoMapper的新手,正在使用6.2.2版。我正在尝试将视图模型映射到实体(也使用Entity Framework)。我只想更新同时存在于视图模型和实体中的属性。该实体具有其他导航属性和相关对象,这些属性不属于源视图模型。我目前收到一个错误,提示我在目标实体上没有映射属性。我的视图模型和实体都具有40多个属性,因此我不想显式地将每个属性添加到地图。

这是我的代码:

地图:

public static void RegisterMaps()
{
    AutoMapper.Mapper.Initialize(config =>
    {
                    config.CreateMap<EditApplicationViewModel, Application>();

    });

}
Run Code Online (Sandbox Code Playgroud)

我也尝试了以下方法,但得到相同的错误:

config.CreateMap<EditApplicationViewModel, Application>(MemberList.source);
Run Code Online (Sandbox Code Playgroud)

控制器:

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(EditApplicationViewModel viewModel)
{
    if (ModelState.IsValid)
    {
        Application application = _applicationService.GetById(viewModel.ApplicationId);

        application = Mapper.Map(viewModel, application);
    }
}
Run Code Online (Sandbox Code Playgroud)

错误信息:

InnerException:HResult = -2146233088消息=找到了未映射的成员。在下面查看类型和成员。添加自定义映射表达式,忽略,添加自定义解析器或修改源/目标类型对于没有匹配的构造函数,请添加no-arg ctor,添加可选参数或映射所有构造函数参数======= ================================================== =字符串->用户(目标成员列表)System.String-> 。***。entities.User(目标成员列表)

未映射的属性:已删除-目标上一长串相关对象和属性

   Source=AutoMapper
   StackTrace:
        at lambda_method(Closure , EditApplicationViewModel , Application , ResolutionContext )
Run Code Online (Sandbox Code Playgroud)

更新:

我还尝试了以下地图。我没有收到任何错误,但没有任何源属性在目标上更新。

config.CreateMap<EditApplicationViewModel, Application>().ForAllOtherMembers(opts=>opts.Ignore());
Run Code Online (Sandbox Code Playgroud)

c# automapper automapper-6

2
推荐指数
1
解决办法
5987
查看次数