小编Sea*_*kit的帖子

为什么这个jQuery点击功能不起作用?

码:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $("#clicker").click(function () {
        alert("Hello!");
        $(".hide_div").hide();
    });
</script>
Run Code Online (Sandbox Code Playgroud)

上面的代码不起作用.当我点击#clicker时,它不会发出警报,也不会隐藏.我检查了控制台,没有错误.我还检查了JQuery是否正在加载,确实是.所以不确定问题是什么.我还做了一个带有警报的文件就绪功能,这样做不能确定我做错了什么.请帮忙.谢谢!

javascript jquery click onclick onclicklistener

112
推荐指数
5
解决办法
27万
查看次数

AutoMapper 5.2如何配置

配置AutoMapper以供全局使用的正确方法是什么.

我想设置一次,然后使用虽然应用程序.

我有一种强烈的感觉,这是错误的.事实上我知道这是错误的,因为这会调用一个新实例.我想要一个全局配置然后你怎么称呼它.找不到一个好例子!

这就是我所拥有的:但它不是我想要的

public static class AutoMapperConfig
{
      public static IMapper GetMapper()
      {
          var config = new MapperConfiguration(cfg => {
              cfg.CreateMap<R_Logo, LogoDto>();
              //lots more maps...?
          });

          IMapper mapper = config.CreateMapper();
          return mapper;
      }
}
Run Code Online (Sandbox Code Playgroud)

然后用法:

  var imapper = AutoMapperConfig.GetMapper();
  var dest = imapper.Map<R_Logo, LogoDto>(logo);
Run Code Online (Sandbox Code Playgroud)

UPDATE基于:pinkfloydx33

调用一次,然后配置完成.

public static class AutoMapperConfig
{
   public static void RegisterMappings()
   {
        AutoMapper.Mapper.Initialize(cfg => {
           cfg.CreateMap<R_Logo, LogoDto>();
            /* etc */
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

c# automapper

12
推荐指数
3
解决办法
3万
查看次数

Select2在HTML中设置选定的值

有没有办法可以在HTML中的select2中设置所选的id/text,就像显示和选择一样?

我正在使用jquery select2版本4.0.0

这是代码:

$("#users").select2({
    placeholder: "select user...",
    escapeMarkup: function (markup) { return markup; },
    ajax: {
        url: "users.json",
        dataType: 'json',
        delay: 250,
        data: function (params) {
            return {
                q: params.term, // search term
                page: params.page
            };
        },
        processResults: function (response, page) {
            return {
                results: response.data
            };
        },
        cache: true
    },
    templateResult: function(item){
        if (item.loading) {
            return item.text;
        }
        return item.username + " <small><i>(" + item.role  + ")</i></small> "; // display data in html
    },
    templateSelection: function(item){
        if (item.username){ …
Run Code Online (Sandbox Code Playgroud)

javascript jquery-select2

8
推荐指数
1
解决办法
4444
查看次数

c#接口,抽象类,强制继承类不是抽象类

是否有继承具有接口的基类来实现该接口的成员.

一些界面

public interface ICanWork
{
     void DoSomething();
}
Run Code Online (Sandbox Code Playgroud)

一些抽象的课

public abstract Class MyBase : ICanWork
{
     // I do not want to implement the ICanWork but instead want the derived class which inherit it
}
Run Code Online (Sandbox Code Playgroud)

我继承基类的类

public class House : MyBase
{
     // i want the compiler to know that it needs to implement ICanWork 
}
Run Code Online (Sandbox Code Playgroud)

这没有像我期望的那样起作用.

通过将接口放在类上继承基类来实现这一目的的唯一方法是什么?

例如

public class House : MyBase, ICanWork
{

}
Run Code Online (Sandbox Code Playgroud)

任何有用的建议?

.net c# oop inheritance interface

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