小编Sta*_*his的帖子

Bluebird Promisfy.each,有for循环和if语句吗?

现在,父for循环(m < repliesIDsArray.length)在第一个findOne触发之前完成,所以这只遍历repliesIDsArray..asynchronous的最后一个元素.

这个代码集的promisified版本的正确语法是什么?是新的promisification,并想知道如何启动这个promisify +循环通过数组+帐户的if语句..

蓝鸟是必需的,并被Promise.promisifyAll(require("mongoose"));称为.

for(var m=0; m<repliesIDsArray.length; m++){

objectID = repliesIDsArray[m];

Models.Message.findOne({ "_id": req.params.message_id},
    function (err, doc) {
        if (doc) {
         // loop over doc.replies to find the index(index1) of objectID at replies[index]._id
         var index1;
         for(var i=0; i<doc.replies.length; i++){
            if (doc.replies[i]._id == objectID) {
                index1 = i;
                break;
            }
         }
         // loop over doc.replies[index1].to and find the index(index2) of res.locals.username at replies[index1].to[index2]
         var index2;
         for(var j=0; j<doc.replies[index1].to.length; j++){
            if (doc.replies[index1].to[j].username === res.locals.username) {
                index2 …
Run Code Online (Sandbox Code Playgroud)

mongoose node.js promise node-mongodb-native bluebird

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

TypeError:variable.getHours(); 是未定义的,其中variable = Date.now()?

我希望得到当前的日期时间,并提取小时,分钟等,以便为消息添加时间戳.

为什么控制台会记录TypeError: Date.datetimeNow is undefined下来:

var datetimeNow = Date.now();
var hourNow = datetimeNow.getHours();
var minuteNow = datetimeNow.getMinutes();
Run Code Online (Sandbox Code Playgroud)

javascript datetime

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

CSS - 设置高度页眉/页脚,动态内容..不在osXsafari/iOSsafari上工作?(jsBin)

我从@ RokoC.Buljan这个伟大的解决方案,但它仅适用于Chrome浏览器和Safari浏览器firefox..on,内容部分不滚动和页脚似乎粘到内容的底部,使其无法..

有没有办法解决Safari/iOSsafari的问题?..或跨浏览器兼容的alt解决方案?

http://jsbin.com/negin/9/edit

HTML:

<div id="view">
  <div id="appear"> Content that appears </div>
  <div id="header"> Header </div>
  <div id="content"> <h1>Content</h1> <p>Lorem ipsum...</p> </div>
  <div id="footer"> Footer </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS(使用calc for dynamic似乎支持,但也许这是问题?):

#view {
  overflow: hidden;           /* NO SCROLLBARS */
  margin: 0 auto;
  background-color: #000;
  color:#fff;

  width: 100vw;
  max-width: 350px;
  height: 100vh;
}
#appear{
  display:none;
}
#header,
#footer {
  height: 44px;               /* note this */
  background-color: #555;
}
#content {
  overflow-y: scroll;         /* SCROLLBARS !!!*/
  height: calc(100% - …
Run Code Online (Sandbox Code Playgroud)

html css jquery cross-browser responsive-design

5
推荐指数
1
解决办法
1347
查看次数

响应式网格布局-仪表板样式-100%高度和宽度的容器

我希望使它成为11个html div的纯响应式CSS网格。

在此处输入图片说明

<div class="dashboard page-container">w100%, h100%
    <div class="box1">w20%, h25%</div>
    <div class="box2">w20%, h25%</div>
    <div class="box3">w20%, h25%</div>
    <div class="box4">w20%, h25%</div>
    <div class="box5">w35%, h30%</div>
    <div class="box6">w30%, h65%</div>
    <div class="box7">w15%, h90%</div>
    <div class="box8">w35%, h35%</div>
    <div class="box9">w65%, h15%</div>
    <div class="box10">w65%, h20%</div>
    <div class="box11">w15%, h10%</div>
</div><!--/dashboard-->
Run Code Online (Sandbox Code Playgroud)

在容器宽度为100%,高度为100%的情况下做出响应,

..每个框占页面容器的百分比。

一直在努力,但仍未使浮子正常工作。

html css css3 grid-layout responsive-design

4
推荐指数
1
解决办法
2567
查看次数

Handlebars.js - 循环除第一个元素之外的数组?

对于引导轮播项目<div class="item">,第一项需要是活动的,
div class="item active">尽管只有第一项

想写一个Handlebars Helper,像这样循环:

  <div class="item active">
    <div class="foo">{{foo.[0]}}</div>
  </div>
{{#each resArray foo}}
  <div class="item">
    <div class="foo">{{this}}</div>
  </div>
{{/each}}
Run Code Online (Sandbox Code Playgroud)

..虽然如何写得正确?

Handlebars.registerHelper("resArray", function(array) {
  return array[1 to array.length];
});
Run Code Online (Sandbox Code Playgroud)

此外,这个助手会去哪里?..在我的节点server.js文件中分配了Handlebars?

javascript node.js express handlebars.js twitter-bootstrap

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