小编Ror*_*san的帖子

Azure DocumentDb错误"查询必须评估为IEnumerable"

尝试检索单个记录时,我在尝试查询Azure DocumentDb存储帐户时遇到问题.这是我的WebAPI代码:

// Controller...
public AccountController : ApiController {
    // other actions...

    [HttpGet]
    [Route("Profile")]
    public HttpResponseMessage Profile()
    {
        var userId = User.Identity.GetUserId();
        var rep = new DocumentRepository<UserDetail>();
        var profile = rep.FindById(userId);

        if (profile == null)
            return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Profile not found");

        return Request.CreateResponse(HttpStatusCode.OK, profile);
    }
}

// Repository
public class DocumentRepository<TEntity> : IDocumentRepository<TEntity> where TEntity : IIdentifiableEntity
{
    private static DocumentClient _client;
    private static string _databaseName;
    private static string _documentsLink;
    private static string _selfLink;

    public DocumentRepository()
    {
        _client = new DocumentClient(new …
Run Code Online (Sandbox Code Playgroud)

c# linq azure azure-cosmosdb

16
推荐指数
1
解决办法
4381
查看次数

使用for循环而不是map返回以小写形式返回数组的所有值

var sorted = words.map(function(value) {
    return value.toLowerCase();
}).sort();
Run Code Online (Sandbox Code Playgroud)

这段代码以小写形式返回单词数组中的所有值并对它们进行排序,但我想对for循环执行相同的操作,但我不能.

我试过了:

for (var i = 0; i < words.length; i++) {
  sorted = [];
  sorted.push(words[i].toLowerCase());
};
Run Code Online (Sandbox Code Playgroud)

javascript

15
推荐指数
4
解决办法
6万
查看次数

如何使用NSURLComponents将+编码到%2B中

我正在使用NSURLComponents,我似乎无法获得正确编码的查询值.我需要最终的URL来表示+as %2B.

let baseUrl = NSURL(string: "http://www.example.com")    
let components = NSURLComponents(URL: baseUrl, resolvingAgainstBaseURL: true)
components.queryItems = [ NSURLQueryItem(name: "name", value: "abc+def") ]
XCTAssertEqual(components!.string!, "http://www.example.com?connectionToken=abc%2Bdef")
Run Code Online (Sandbox Code Playgroud)

失败!

输出等于:

http://www.example.com?connectionToken=abc+def 
Run Code Online (Sandbox Code Playgroud)

http://www.example.com?connectionToken=abc%2Bdef
Run Code Online (Sandbox Code Playgroud)

我已经尝试了几种变化,我似乎无法将其输出%2B.

encoding nsurl url-encoding swift

15
推荐指数
3
解决办法
3706
查看次数

获得咏叹调的价值

我没有找到从DOM获得aria扩展值的方法.

<a class="accordion-toggle collapsed" href="#collapse-One" data-parent="#accordion-1" data-toggle="collapse" aria-expanded="false">
    <i class="fa fa-search-plus"></i>
    test
</a>
Run Code Online (Sandbox Code Playgroud)

我想测试是否true可以将<i>课程更改为fa-search-minus.我试过这个,但我总是得到一个未定义的值:

console.log($(this).find('a.aria-expanded').val());
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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

触发文件输入对话框

如何自动触发文件输入?即.在下面的链接中我想在加载时触发上传按钮

DEMO

<form id="test_form">
    <input type="file" id="test">
    <div id="test1">
        <button>Upload</button>
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)
$("#test1").trigger('click');
$("#test").trigger('click');
Run Code Online (Sandbox Code Playgroud)

javascript jquery

15
推荐指数
4
解决办法
3894
查看次数

如何使用jQuery和dataTables进行数字排序?

我正在使用DataTables jQuery插件.我正在尝试启用排序交互,但在排序时,它按字母顺序排序,而不是数字排序.正如您在-4317.93附图中所见,显示在-631和之后-456.如何DataTable以数字方式对列进行排序?

例

javascript jquery datatables

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

jQuery UI可排序容差选项无法按预期工作

以下是该选项的jQuery UI文档中部分tolerance:

这是重新排序在拖动过程中的行为方式.可能的值:'intersect','pointer'.在某些设置中,"指针"更自然.

相交:draggable重叠至少50%的droppable

默认值是intersect,但是如果鼠标指针不在可排序项目之上,则排序不会发生,无论被拖动元素是否比其他可排序项目至少高50%(我期望的功能)这在演示页面上发生好(上面链接)

这是jQuery UI中的错误,还是我理解错了?

jquery jquery-ui jquery-ui-sortable

14
推荐指数
3
解决办法
7927
查看次数

如何使用jQuery更改日期格式?

我有一个像这样的格式的日期fecha2.value = '2014-01-06',但我想'01-06-14'使用jQuery 将格式更改为this .

我怎样才能做到这一点?提前致谢.

javascript jquery date-format

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

Jetbrains PHPStorm 5.0.4告诉我我有一个重复的jQuery选择器

这是我写的jQuery,

$('#editUser').click(function() {
    if ($(".selectedTR")[0]) {
        if($('.form-actions').is(':visible')) {
            $('.form-actions').slideUp('slow',function() {
                $('.form-actions > h3').text("Edit");
            }).css('display', 'none');
        }

        $('.form-actions').css('display', 'block').slideDown('slow');
    } else {
        alert("Please select a user");
    }
});
Run Code Online (Sandbox Code Playgroud)

如何删除重复的选择器?

javascript jquery

13
推荐指数
1
解决办法
7912
查看次数

如何在async/await和typescript中使用jQuery的$ .post()方法

异步函数中的我的await语句是对jQuery的$ .post()方法的调用,该方法返回一个有效的promise,但是我在TypeScript中遇到了这个错误:

'await'操作数的类型必须是有效的promise或者不能包含可调用的'then'成员.

我的功能是这个(示例简化).代码有效且有效,但我在TS控制台中收到错误.

 async function doAsyncPost() {
    const postUrl = 'some/url/';
    const postData = {name: 'foo', value: 'bar'};
    let postResult;
    let upateResult;

    function failed(message: string, body?: string) {
      console.log('error: ', message, ' body: ', body);
    }

    function promiseFunc() {
      return new Promise<void>( resolve => {
        // ... do something else....
        resolve();
      });
    };

    function finish() {
      // ... do something at the end...
    }

    try {
      // The error is on the $.post()
      postResult = await $.post(postUrl, $.param(postData));
      if …
Run Code Online (Sandbox Code Playgroud)

jquery typescript es6-promise

13
推荐指数
1
解决办法
9979
查看次数